summary refs log tree commit diff stats
path: root/tests/qemu-iotests/testrunner.py
diff options
context:
space:
mode:
authorEmanuele Giuseppe Esposito <eesposit@redhat.com>2021-05-10 21:04:49 +0200
committerMax Reitz <mreitz@redhat.com>2021-05-14 16:14:10 +0200
commitac4e14f5dc93d6b4bc5d4849bb61810023330380 (patch)
tree907008ea2c221072539674581b492c74a0c89266 /tests/qemu-iotests/testrunner.py
parentbcc8584c832f7a52fd8c64483dd452c1baf01db7 (diff)
downloadfocaccia-qemu-ac4e14f5dc93d6b4bc5d4849bb61810023330380.tar.gz
focaccia-qemu-ac4e14f5dc93d6b4bc5d4849bb61810023330380.zip
qemu-iotests: fix pylint 2.8 consider-using-with error
pylint 2.8 introduces consider-using-with error, suggesting
to use the 'with' block statement when possible.

Modify all subprocess.Popen call to use the 'with' statement,
except the one in __init__ of QemuIoInteractive class, since
it is assigned to a class field and used in other methods.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Message-Id: <20210510190449.65948-1-eesposit@redhat.com>
[mreitz: Disable bad-option-value warning in the iotests' pylintrc, so
         that disabling consider-using-with in QemuIoInteractive will
         not produce a warning in pre-2.8 pylint versions]
Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/testrunner.py')
-rw-r--r--tests/qemu-iotests/testrunner.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py
index 2f56ac545d..4a6ec421ed 100644
--- a/tests/qemu-iotests/testrunner.py
+++ b/tests/qemu-iotests/testrunner.py
@@ -246,17 +246,17 @@ class TestRunner(ContextManager['TestRunner']):
 
         t0 = time.time()
         with f_bad.open('w', encoding="utf-8") as f:
-            proc = subprocess.Popen(args, cwd=str(f_test.parent), env=env,
-                                    stdout=f, stderr=subprocess.STDOUT)
-            try:
-                proc.wait()
-            except KeyboardInterrupt:
-                proc.terminate()
-                proc.wait()
-                return TestResult(status='not run',
-                                  description='Interrupted by user',
-                                  interrupted=True)
-            ret = proc.returncode
+            with subprocess.Popen(args, cwd=str(f_test.parent), env=env,
+                                  stdout=f, stderr=subprocess.STDOUT) as proc:
+                try:
+                    proc.wait()
+                except KeyboardInterrupt:
+                    proc.terminate()
+                    proc.wait()
+                    return TestResult(status='not run',
+                                      description='Interrupted by user',
+                                      interrupted=True)
+                ret = proc.returncode
 
         elapsed = round(time.time() - t0, 1)