MCPcopy
hub / github.com/pytest-dev/pytest / lsof_check

Function lsof_check

testing/test_capture.py:1016–1032  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1014
1015@contextlib.contextmanager
1016def lsof_check():
1017 pid = os.getpid()
1018 try:
1019 out = subprocess.check_output(("lsof", "-p", str(pid)), timeout=10).decode()
1020 except (
1021 OSError,
1022 UnicodeDecodeError,
1023 subprocess.CalledProcessError,
1024 subprocess.TimeoutExpired,
1025 ) as exc:
1026 # about UnicodeDecodeError, see note on pytester
1027 pytest.skip(f"could not run 'lsof' ({exc!r})")
1028 yield
1029 out2 = subprocess.check_output(("lsof", "-p", str(pid))).decode()
1030 len1 = len([x for x in out.split("\n") if "REG" in x])
1031 len2 = len([x for x in out2.split("\n") if "REG" in x])
1032 assert len2 < len1 + 3, out2
1033
1034
1035class TestFDCapture:

Callers 2

test_manyMethod · 0.85

Calls 1

check_outputMethod · 0.80

Tested by

no test coverage detected