diff options
| author | Donatas Abraitis <donatas.abraitis@gmail.com> | 2021-05-10 20:11:47 +0300 |
|---|---|---|
| committer | Donatas Abraitis <donatas.abraitis@gmail.com> | 2021-05-11 14:14:26 +0300 |
| commit | 764b81858f6c55153bc99bae3be5aeab92f59f05 (patch) | |
| tree | b0a7dab3eda4cc47a69c5e08988adf9b174be1f3 /tests/topotests/example_test/test_example.py | |
| parent | 9ce686504743ff65ed0ca5ad2d8f10d35519041a (diff) | |
tests: Unify directory naming for topotests
Change every `-` to `_` in directory names. This is to avoid mixing _ and -.
Just for consistency and directory sorting properly.
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
Diffstat (limited to 'tests/topotests/example_test/test_example.py')
| -rwxr-xr-x | tests/topotests/example_test/test_example.py | 69 |
1 files changed, 69 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..72eceee612 --- /dev/null +++ b/tests/topotests/example_test/test_example.py @@ -0,0 +1,69 @@ +#!/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) |
