diff options
| author | Rafael Zalamena <rzalamena@gmail.com> | 2017-06-29 10:46:19 -0300 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-11-27 20:22:11 -0500 |
| commit | b06e9eff759fdfc3591ed8c0336879b4609bbf98 (patch) | |
| tree | 75d35a8c5fafbecb27ce596ac0972f37237d6c04 | |
| parent | a40daddc4c7c3e0f30f2a136a9ae9165e351bcdc (diff) | |
template: allow test to be run without pytest
Update the PYTHONPATH for standalone runs and pass all command line
arguments to pytest main. Also set the executable bit to the python
scripts file.
| -rwxr-xr-x[-rw-r--r--] | tests/topotests/example-test/__init__.py | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | tests/topotests/example-test/test_template.py | 11 |
2 files changed, 7 insertions, 4 deletions
diff --git a/tests/topotests/example-test/__init__.py b/tests/topotests/example-test/__init__.py index e69de29bb2..e69de29bb2 100644..100755 --- a/tests/topotests/example-test/__init__.py +++ b/tests/topotests/example-test/__init__.py diff --git a/tests/topotests/example-test/test_template.py b/tests/topotests/example-test/test_template.py index ac6faeaa63..b7556458a2 100644..100755 --- a/tests/topotests/example-test/test_template.py +++ b/tests/topotests/example-test/test_template.py @@ -30,6 +30,11 @@ import os import sys import pytest +# Save the Current Working Directory to find configuration files. +CWD = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(CWD, '../')) + +# pylint: disable=C0413 # Import topogen and topotest helpers from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen @@ -37,9 +42,6 @@ from lib.topogen import Topogen, TopoRouter, get_topogen # Required to instantiate the topology builder class. from mininet.topo import Topo -# Save the Current Working Directory to find configuration files. -CWD = os.path.dirname(os.path.realpath(__file__)) - class TemplateTopo(Topo): "Test topology builder" def build(self, *_args, **_opts): @@ -99,4 +101,5 @@ def test_call_mininet_cli(): tgen.mininet_cli() if __name__ == '__main__': - sys.exit(pytest.main(["-s"])) + args = ["-s"] + sys.argv[1:] + sys.exit(pytest.main(args)) |
