diff --git a/tests/integration/rancherostest/conftest.py b/tests/integration/rancherostest/conftest.py new file mode 100644 index 00000000..df90dba5 --- /dev/null +++ b/tests/integration/rancherostest/conftest.py @@ -0,0 +1,8 @@ +import os +import pytest + + +@pytest.fixture(scope="session", autouse=True) +def my_own_session_run_at_beginning(): + os.chdir('../..') + print('\nChdir to project root dir') diff --git a/tests/integration/rancherostest/test_system.py b/tests/integration/rancherostest/test_system.py index a4dbe61b..f4cd69d1 100644 --- a/tests/integration/rancherostest/test_system.py +++ b/tests/integration/rancherostest/test_system.py @@ -1,21 +1,25 @@ -import os +import pytest import string import subprocess -import pytest + + +@pytest.fixture(scope="module") +def qemu(request): + p = subprocess.Popen('./scripts/run', stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + + def fin(): + p.stdout.close() + p.terminate() + + request.addfinalizer(fin) + return p @pytest.mark.timeout(20) -def test_system_boot(): - os.chdir('../..') - p = subprocess.Popen('./scripts/run', stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - try: - for ln in iter(p.stdout.readline, ''): - l = string.strip(ln) - ros_booted_substr = string.find(l, 'RancherOS v0.3.1-rc2 started') - if ros_booted_substr > -1: - assert True - return - finally: - p.stdout.close() - p.terminate() - p.wait() +def test_system_boot(qemu): + for ln in iter(qemu.stdout.readline, ''): + l = string.strip(ln) + ros_booted_substr = string.find(l, 'RancherOS v0.3.1-rc2 started') + if ros_booted_substr > -1: + assert True + return