diff --git a/slycot/tests/test_exceptions.py b/slycot/tests/test_exceptions.py index b370c34e..28614ce5 100644 --- a/slycot/tests/test_exceptions.py +++ b/slycot/tests/test_exceptions.py @@ -93,6 +93,55 @@ def test_unhandled_info_iwarn(): assert wm[1].message.info == 0 +def test_info_standard_i(): + """Test the handling of standard "`info = -i` + + Raises + ------ + SlycotError + :info = -i: Non-standard msg, info is {info}, -i is -{i} + """ + # No i in check_vars: keep silent + raise_if_slycot_error(-1, docstring=test_info_standard_i.__doc__, + checkvars={'a': 1}) + # -i does not match + raise_if_slycot_error(-1, docstring=test_info_standard_i.__doc__, + checkvars={'i': 2}) + # -i matches, raise the error + with pytest.raises(SlycotError) as ex_info: + raise_if_slycot_error(-1, docstring=test_info_standard_i.__doc__, + checkvars={'i': 1}) + assert str(ex_info.value) == "\nNon-standard msg, info is -1, -i is -1" + + +def test_infospec_nameerror(): + """Test infospec with unknown variable. + + Raises + ------ + SlycotError + :info = v: We do not know {v} + """ + with pytest.raises(RuntimeError) as ex_info: + raise_if_slycot_error(-1, docstring=test_infospec_nameerror.__doc__, + checkvars={'a': 1}) + assert str(ex_info.value) == "Unknown variable in infospec: info = v" + + +def test_infospec_syntaxerror(): + """Test invalid infospec. + + Raises + ------ + SlycotError + :info i: Invalid expression + """ + with pytest.raises(RuntimeError) as ex_info: + raise_if_slycot_error(-1, docstring=test_infospec_syntaxerror.__doc__, + checkvars={'i': 1}) + assert str(ex_info.value) == "Invalid infospec: info i" + + # Test code for test_xerbla_override CODE = """ import sys