Skip to content

Commit 7d87afe

Browse files
authored
Re-add tests/ directory for coverage (#3314)
1 parent 0ae6e62 commit 7d87afe

File tree

3 files changed

+9
-22
lines changed

3 files changed

+9
-22
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ omit = [
311311
parallel = true
312312
plugins = []
313313
relative_files = true
314-
source = ["trio"]
314+
source = ["trio", "tests/", "_trio_check_attrs_aliases"]
315315

316316
[tool.coverage.report]
317317
precision = 1

src/trio/_core/_tests/test_thread_cache.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -220,23 +220,8 @@ def foo() -> None:
220220
if child_pid != 0:
221221
# if this test fails, this will hang, triggering a timeout.
222222
os.waitpid(child_pid, 0)
223-
else:
224-
# this is necessary because os._exit doesn't unwind the stack,
225-
# so coverage doesn't get to automatically stop and save
226-
# coverage information.
227-
try:
228-
import coverage
229-
230-
cov = coverage.Coverage.current()
231-
# the following pragmas are necessary because if coverage:
232-
# - isn't running, then it can't record the branch not
233-
# taken
234-
# - isn't installed, then it can't record the ImportError
235-
236-
if cov: # pragma: no branch
237-
cov.stop()
238-
cov.save()
239-
except ImportError: # pragma: no cover
240-
pass
241-
242-
os._exit(0) # pragma: no cover # coverage was stopped above.
223+
else: # pragma: no cover # coverage is shut down by os._exit(0)
224+
# we would *want* to allow coverage to take a snapshot here. check
225+
# git blame for how to do that. however, that times out for some
226+
# reason when having `tests/` in `source` for coverage.py.
227+
os._exit(0)

src/trio/_core/_thread_cache.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,9 @@ def start_thread_soon(
303303
THREAD_CACHE.start_thread_soon(fn, deliver, name)
304304

305305

306-
def clear_worker_threads() -> None:
306+
def clear_worker_threads() -> (
307+
None
308+
): # pragma: no cover # see test_clear_thread_cache_after_fork
307309
# This is OK because the child process does not actually have any
308310
# worker threads. Additionally, while WorkerThread keeps a strong
309311
# reference and so would get affected, the only place those are

0 commit comments

Comments
 (0)