diff options
| author | Christian Franke <nobody@nowhere.ws> | 2018-11-29 15:29:08 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-29 15:29:08 +0100 |
| commit | f2ce6a57a86a87b2d38fd5e01bc4ddff3c055005 (patch) | |
| tree | c3d881be5c70f643269704c6d3a7b626ae589b5d /tests/topotests/example-test/test_example.py | |
| parent | d5215d5e169957de399334c2150116ca2fbd0d63 (diff) | |
| parent | 096694da4793bfc199b1a3698b932d0b59de6956 (diff) | |
Merge pull request #3384 from donaldsharp/topotests
Topotests
Diffstat (limited to 'tests/topotests/example-test/test_example.py')
| -rwxr-xr-x | tests/topotests/example-test/test_example.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/topotests/example-test/test_example.py b/tests/topotests/example-test/test_example.py new file mode 100755 index 0000000000..8e37ad11d4 --- /dev/null +++ b/tests/topotests/example-test/test_example.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +import subprocess +import sys +import os +import time + +import pytest + +fatal_error = "" + +def setup_module(module): + print ("setup_module module:%s" % module.__name__) + +def teardown_module(module): + print ("teardown_module module:%s" % module.__name__) + +def setup_function(function): + print ("setup_function function:%s" % function.__name__) + +def teardown_function(function): + print ("teardown_function function:%s" % function.__name__) + +def test_numbers_compare(): + a = 12 + print ("Dummy Output") + assert( a == 12 ) + +def test_fail_example(): + assert True, "Some Text with explaination in case of failure" + +def test_ls_exits_zero(): + "Tests for ls command on invalid file" + + global fatal_error + + proc = subprocess.Popen( + ["ls", "/some/nonexistant/file"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + stdout, stderr = proc.communicate() + + if (proc.returncode != 0): + # Mark this as a fatal error which skips some other tests on failure + fatal_error = "test_fail_example failed" + assert proc.returncode == 0, "Return Code is non-Zero:\n%s" % stderr + +def test_skipped_on_fatalerror(): + global fatal_error + + # Skip if previous fatal error condition is raised + if (fatal_error != ""): + pytest.skip(fatal_error) + + assert True, "Some Text with explaination in case of failure" + +if __name__ == '__main__': + retval = pytest.main(["-s"]) + sys.exit(retval) |
