Skip to content

Commit 1024886

Browse files
MaisenbacherDigaw
authored andcommitted
tests: Fix subprosess.call calls
Don't use stdout=PIPE with subprocess.call as noted in the documentation: https://docs.python.org/3/library/subprocess.html#subprocess.call Signed-off-by: Dennis Maisenbacher <[email protected]>
1 parent 7baebb9 commit 1024886

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

tests/nvme_test.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ def nvme_reset_ctrl(self):
167167
nvme_reset_cmd = f"{self.nvme_bin} reset {self.ctrl}"
168168
err = subprocess.call(nvme_reset_cmd,
169169
shell=True,
170-
stdout=subprocess.PIPE,
171-
encoding='utf-8')
170+
stdout=subprocess.DEVNULL)
172171
self.assertEqual(err, 0, "ERROR : nvme reset failed")
173172
rescan_cmd = "echo 1 > /sys/bus/pci/rescan"
174173
proc = subprocess.Popen(rescan_cmd,
@@ -392,8 +391,7 @@ def create_and_validate_ns(self, nsid, nsze, ncap, flbas, dps):
392391
f"--namespace-id={str(nsid)}"
393392
err = subprocess.call(id_ns_cmd,
394393
shell=True,
395-
stdout=subprocess.PIPE,
396-
encoding='utf-8')
394+
stdout=subprocess.DEVNULL)
397395
return err
398396

399397
def attach_ns(self, ctrl_id, ns_id):
@@ -408,8 +406,7 @@ def attach_ns(self, ctrl_id, ns_id):
408406
f"--namespace-id={str(ns_id)} --controllers={ctrl_id}"
409407
err = subprocess.call(attach_ns_cmd,
410408
shell=True,
411-
stdout=subprocess.PIPE,
412-
encoding='utf-8')
409+
stdout=subprocess.DEVNULL)
413410
if err == 0:
414411
# enumerate new namespace block device
415412
self.nvme_reset_ctrl()
@@ -429,8 +426,7 @@ def detach_ns(self, ctrl_id, nsid):
429426
f"--namespace-id={str(nsid)} --controllers={ctrl_id}"
430427
return subprocess.call(detach_ns_cmd,
431428
shell=True,
432-
stdout=subprocess.PIPE,
433-
encoding='utf-8')
429+
stdout=subprocess.DEVNULL)
434430

435431
def delete_and_validate_ns(self, nsid):
436432
""" Wrapper for deleting and validating that namespace is deleted.
@@ -444,8 +440,7 @@ def delete_and_validate_ns(self, nsid):
444440
f"--namespace-id={str(nsid)}"
445441
err = subprocess.call(delete_ns_cmd,
446442
shell=True,
447-
stdout=subprocess.PIPE,
448-
encoding='utf-8')
443+
stdout=subprocess.DEVNULL)
449444
self.assertEqual(err, 0, "ERROR : delete namespace failed")
450445
return err
451446

0 commit comments

Comments
 (0)