From cfe1993dc793185d82ed9f1aa3a78c63a1a36c8e Mon Sep 17 00:00:00 2001 From: bnavigator Date: Mon, 13 Apr 2020 21:12:55 +0200 Subject: [PATCH] run examples in testsuite --- slycot/tests/CMakeLists.txt | 1 + slycot/tests/test_examples.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 slycot/tests/test_examples.py diff --git a/slycot/tests/CMakeLists.txt b/slycot/tests/CMakeLists.txt index 0b021358..912e9717 100644 --- a/slycot/tests/CMakeLists.txt +++ b/slycot/tests/CMakeLists.txt @@ -4,6 +4,7 @@ set(PYSOURCE test.py test_ab08n.py test_ag08bd.py + test_examples.py test_mb.py test_mc.py test_sb10jd.py diff --git a/slycot/tests/test_examples.py b/slycot/tests/test_examples.py new file mode 100755 index 00000000..b926e2ea --- /dev/null +++ b/slycot/tests/test_examples.py @@ -0,0 +1,29 @@ +""" + +test_examples.py + + +""" + +from inspect import getmembers, isfunction +import pytest + +from slycot import examples + +examplefunctions = [fun for (fname, fun) in getmembers(examples) + if isfunction(fun) and "_example" in fname] + + +@pytest.mark.parametrize('examplefun', examplefunctions) +def test_example(examplefun, capsys, recwarn): + """ + Test the examples. + + Test that all the examples work, produce some (unchecked) output but no + exceptions or warnings. + """ + examplefun() + captured = capsys.readouterr() + assert len(captured.out) > 0 + assert not captured.err + assert not recwarn