Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
make test_example more verbose on failures
  • Loading branch information
bnavigator committed May 24, 2020
commit 36ceb478b1a88fdb00eae9eca036716a7bb057f5
5 changes: 3 additions & 2 deletions slycot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ configure_file(version.py.in version.py @ONLY)

set(PYSOURCE

__init__.py analysis.py examples.py math.py synthesis.py
transform.py ${CMAKE_CURRENT_BINARY_DIR}/version.py)
__init__.py examples.py exceptions.py
analysis.py math.py synthesis.py transform.py
${CMAKE_CURRENT_BINARY_DIR}/version.py)

set(SLYCOT_MODULE "_wrapper")
find_package(PythonExtensions REQUIRED)
Expand Down
21 changes: 18 additions & 3 deletions slycot/tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
if isfunction(fun) and "_example" in fname]


#ignore numpy ABI changes https://github.com/numpy/numpy/pull/432
@pytest.mark.parametrize('examplefun', examplefunctions)
@pytest.mark.filterwarnings("ignore:numpy.dtype size changed")
@pytest.mark.filterwarnings("ignore:numpy.ufunc size changed")
def test_example(examplefun, capsys, recwarn):
"""
Test the examples.
Expand All @@ -24,6 +27,18 @@ def test_example(examplefun, capsys, recwarn):
"""
examplefun()
captured = capsys.readouterr()
assert len(captured.out) > 0
assert not captured.err
assert not recwarn

# fail for first in order
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")]
for failed, msgfmt in failconditions:
if failed:
pytest.fail(msgfmt.format(examplefun.__name__) +
"Captured output:\n{}\n"
"Captured stderr:\n{}\n"
"Captured warnings:\n{}\n"
"".format(captured.out,
captured.err,
[w.message for w in recwarn]))