1
0
mirror of https://github.com/rancher/os.git synced 2025-08-01 15:08:47 +00:00

integration tests: use session and module fixtures

This commit is contained in:
Ivan Mikushin 2015-05-07 19:49:54 +05:00
parent e4f04c698f
commit 38d67b20d1
2 changed files with 28 additions and 16 deletions

View File

@ -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')

View File

@ -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