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

Method get_open_files

src/_pytest/pytester.py:125–154  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

123
124class LsofFdLeakChecker:
125 def get_open_files(self) -> List[Tuple[str, str]]:
126 out = subprocess.run(
127 ("lsof", "-Ffn0", "-p", str(os.getpid())),
128 stdout=subprocess.PIPE,
129 stderr=subprocess.DEVNULL,
130 check=True,
131 universal_newlines=True,
132 ).stdout
133
134 def isopen(line: str) -> bool:
135 return line.startswith("f") and (
136 "deleted" not in line
137 and "mem" not in line
138 and "txt" not in line
139 and "cwd" not in line
140 )
141
142 open_files = []
143
144 for line in out.split("\n"):
145 if isopen(line):
146 fields = line.split("\0")
147 fd = fields[0][1:]
148 filename = fields[1][1:]
149 if filename in IGNORE_PAM:
150 continue
151 if filename.startswith("/"):
152 open_files.append((fd, filename))
153
154 return open_files
155
156 def matching_platform(self) -> bool:
157 try:

Callers 1

Calls 2

appendMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected