Skip to content

Commit 237f690

Browse files
committed
--lsof: suppress stderr
This can spam a lot of warnings (per invocation), e.g.: > lsof: WARNING: can't stat() nsfs file system /run/docker/netns/default Output information may be incomplete. Or from Travis/MacOS: > lsof: WARNING: can't stat() vmhgfs file system /Volumes/VMware Shared Folders > Output information may be incomplete. > assuming "dev=31000003" from mount table
1 parent 386e801 commit 237f690

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)