Skip to content

Commit 67dd10d

Browse files
authored
Merge pull request #4763 from blueyed/lsof
--lsof: suppress stderr
2 parents dc8af18 + 237f690 commit 67dd10d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/_pytest/pytester.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ def get_open_files(self):
8181

8282
def _exec_lsof(self):
8383
pid = os.getpid()
84-
return subprocess.check_output(("lsof", "-Ffn0", "-p", str(pid))).decode()
84+
# py3: use subprocess.DEVNULL directly.
85+
with open(os.devnull, "wb") as devnull:
86+
return subprocess.check_output(
87+
("lsof", "-Ffn0", "-p", str(pid)), stderr=devnull
88+
).decode()
8589

8690
def _parse_lsof_output(self, out):
8791
def isopen(line):

0 commit comments

Comments
 (0)