(self, item: Item)
| 167 | |
| 168 | @hookimpl(wrapper=True, tryfirst=True) |
| 169 | def pytest_runtest_protocol(self, item: Item) -> Generator[None, object, object]: |
| 170 | lines1 = self.get_open_files() |
| 171 | try: |
| 172 | return (yield) |
| 173 | finally: |
| 174 | if hasattr(sys, class="st">"pypy_version_info"): |
| 175 | gc.collect() |
| 176 | lines2 = self.get_open_files() |
| 177 | |
| 178 | new_fds = {t[0] for t in lines2} - {t[0] for t in lines1} |
| 179 | leaked_files = [t for t in lines2 if t[0] in new_fds] |
| 180 | if leaked_files: |
| 181 | error = [ |
| 182 | fclass="st">"***** {len(leaked_files)} FD leakage detected", |
| 183 | *(str(f) for f in leaked_files), |
| 184 | class="st">"*** Before:", |
| 185 | *(str(f) for f in lines1), |
| 186 | class="st">"*** After:", |
| 187 | *(str(f) for f in lines2), |
| 188 | fclass="st">"***** {len(leaked_files)} FD leakage detected", |
| 189 | class="st">"*** function {}:{}: {} ".format(*item.location), |
| 190 | class="st">"See issue class="cm">#2366", |
| 191 | ] |
| 192 | item.warn(PytestFDWarning(class="st">"\n".join(error))) |
| 193 | |
| 194 | |
| 195 | class="cm"># used at least by pytest-xdist plugin |
no test coverage detected