()
| 1014 | |
| 1015 | @contextlib.contextmanager |
| 1016 | def 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 | |
| 1035 | class TestFDCapture: |
no test coverage detected