()
| 940 | |
| 941 | @contextlib.contextmanager |
| 942 | def 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 | |
| 956 | class TestFDCapture: |
no test coverage detected