mirror of
https://github.com/rancher/os.git
synced 2025-09-20 10:03:59 +00:00
use with
to close streams properly
This commit is contained in:
@@ -12,7 +12,6 @@ def qemu(request):
|
|||||||
|
|
||||||
def fin():
|
def fin():
|
||||||
print('\nTerminating QEMU')
|
print('\nTerminating QEMU')
|
||||||
p.stdout.close()
|
|
||||||
p.terminate()
|
p.terminate()
|
||||||
|
|
||||||
request.addfinalizer(fin)
|
request.addfinalizer(fin)
|
||||||
@@ -30,7 +29,8 @@ def rancheros_version():
|
|||||||
|
|
||||||
@pytest.mark.timeout(30)
|
@pytest.mark.timeout(30)
|
||||||
def test_system_boot(qemu):
|
def test_system_boot(qemu):
|
||||||
for ln in iter(qemu.stdout.readline, ''):
|
with qemu.stdout as f:
|
||||||
|
for ln in iter(f.readline, ''):
|
||||||
ros_booted_substr = str.find(ln, 'RancherOS {v} started'.format(v=rancheros_version()))
|
ros_booted_substr = str.find(ln, 'RancherOS {v} started'.format(v=rancheros_version()))
|
||||||
print(str.strip(ln))
|
print(str.strip(ln))
|
||||||
if ros_booted_substr > -1:
|
if ros_booted_substr > -1:
|
||||||
@@ -54,12 +54,11 @@ def test_run_system_container(qemu):
|
|||||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for ln in iter(ssh.stdout.readline, ''):
|
with ssh.stdout as f:
|
||||||
|
for ln in iter(f.readline, ''):
|
||||||
print(str.strip(ln))
|
print(str.strip(ln))
|
||||||
pass
|
|
||||||
ssh.wait()
|
ssh.wait()
|
||||||
assert ssh.returncode == 0
|
assert ssh.returncode == 0
|
||||||
finally:
|
finally:
|
||||||
ssh.stdout.close()
|
|
||||||
if ssh.returncode is None:
|
if ssh.returncode is None:
|
||||||
ssh.terminate()
|
ssh.terminate()
|
||||||
|
Reference in New Issue
Block a user