Skip to content

Commit

Permalink
cover docstring parser standard info = -i cases
Browse files Browse the repository at this point in the history
  • Loading branch information
bnavigator committed Jan 9, 2024
1 parent 11a80eb commit a0ee90c
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions slycot/tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a0ee90c

Please sign in to comment.