MCPcopy Create free account
hub / github.com/pytest-dev/pytest / lsof_check

Function lsof_check

testing/test_capture.py:942–953  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

940
941@contextlib.contextmanager
942def lsof_check():
943 pid = os.getpid()
944 try:
945 out = subprocess.check_output(("lsof", "-p", str(pid))).decode()
946 except (OSError, subprocess.CalledProcessError, UnicodeDecodeError) as exc:
947 # about UnicodeDecodeError, see note on pytester
948 pytest.skip(f"could not run 'lsof' ({exc!r})")
949 yield
950 out2 = subprocess.check_output(("lsof", "-p", str(pid))).decode()
951 len1 = len([x for x in out.split("\n") if "REG" in x])
952 len2 = len([x for x in out2.split("\n") if "REG" in x])
953 assert len2 < len1 + 3, out2
954
955
956class TestFDCapture:

Callers 2

test_manyMethod · 0.85

Calls 1

check_outputMethod · 0.80

Tested by

no test coverage detected