summaryrefslogtreecommitdiff
path: root/tests/topotests/example-test/test_example.py
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@users.noreply.github.com>2020-04-05 13:20:30 -0400
committerGitHub <noreply@github.com>2020-04-05 13:20:30 -0400
commita5ba758e615524b301af03aada2ae0c589b0fe64 (patch)
tree96d412e84f76b35760a44e120d98e2b26b62292d /tests/topotests/example-test/test_example.py
parente3770cdbdd640d3daf524b503173ef62af185b52 (diff)
parent787e762445d50ca5b52fafcf8dd6de08ab90916f (diff)
Merge pull request #6144 from ton31337/fix/python_formatter
tests: Run python formatter (black) for topotests
Diffstat (limited to 'tests/topotests/example-test/test_example.py')
-rwxr-xr-xtests/topotests/example-test/test_example.py33
1 files changed, 21 insertions, 12 deletions
diff --git a/tests/topotests/example-test/test_example.py b/tests/topotests/example-test/test_example.py
index 8e37ad11d4..72eceee612 100755
--- a/tests/topotests/example-test/test_example.py
+++ b/tests/topotests/example-test/test_example.py
@@ -9,52 +9,61 @@ import pytest
fatal_error = ""
+
def setup_module(module):
- print ("setup_module module:%s" % module.__name__)
+ print("setup_module module:%s" % module.__name__)
+
def teardown_module(module):
- print ("teardown_module module:%s" % module.__name__)
+ print("teardown_module module:%s" % module.__name__)
+
def setup_function(function):
- print ("setup_function function:%s" % function.__name__)
+ print("setup_function function:%s" % function.__name__)
+
def teardown_function(function):
- print ("teardown_function function:%s" % function.__name__)
+ print("teardown_function function:%s" % function.__name__)
+
def test_numbers_compare():
a = 12
- print ("Dummy Output")
- assert( 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,
+ ["ls", "/some/nonexistant/file"],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
)
stdout, stderr = proc.communicate()
- if (proc.returncode != 0):
+ 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 != ""):
+ if fatal_error != "":
pytest.skip(fatal_error)
assert True, "Some Text with explaination in case of failure"
-if __name__ == '__main__':
+
+if __name__ == "__main__":
retval = pytest.main(["-s"])
sys.exit(retval)