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