Skip to content

Commit

Permalink
allow ab13fd_example to warn about computation of beta(A)
Browse files Browse the repository at this point in the history
  • Loading branch information
bnavigator committed May 24, 2020
1 parent 443577d commit af98e9f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions slycot/tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,25 @@
examplefunctions = [fun for (fname, fun) in getmembers(examples)
if isfunction(fun) and "_example" in fname]

# Exempt certain functions to produce warnings with attributes (iwarn, info)
#
# Failed to compute beta(A) within the specified tolerance
examples.ab13fd_example.allow_iwarninfo = [(None, 1)]


def check_warn(recwarn, examplefun):
"""Returns True if a warning occurs that is not exempt"""
for w in recwarn:
try:
if (w.message.iwarn, w.message.info) in examplefun.allow_iwarninfo:
continue
except AttributeError:
pass
return True


#ignore numpy ABI changes https://github.com/numpy/numpy/pull/432
@pytest.mark.parametrize('examplefun', examplefunctions)
#ignore numpy ABI change warnings https://github.com/numpy/numpy/pull/432
@pytest.mark.filterwarnings("ignore:numpy.dtype size changed")
@pytest.mark.filterwarnings("ignore:numpy.ufunc size changed")
def test_example(examplefun, capsys, recwarn):
Expand All @@ -32,7 +48,7 @@ def test_example(examplefun, capsys, recwarn):
failconditions = [
((not len(captured.out) > 0), "Example {} did not print any results\n"),
(captured.err, "Example {} wrote to stderr\n"),
(recwarn, "Example {} produced a warning.\n")]
(check_warn(recwarn, examplefun), "Example {} produced a warning.\n")]
for failed, msgfmt in failconditions:
if failed:
pytest.fail(msgfmt.format(examplefun.__name__) +
Expand Down

0 comments on commit af98e9f

Please sign in to comment.