Skip to content
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ omit = [
parallel = true
plugins = []
relative_files = true
source = ["trio"]
source = ["trio", "tests/", "_trio_check_attrs_aliases"]

[tool.coverage.report]
precision = 1
Expand Down
25 changes: 5 additions & 20 deletions src/trio/_core/_tests/test_thread_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,23 +220,8 @@ def foo() -> None:
if child_pid != 0:
# if this test fails, this will hang, triggering a timeout.
os.waitpid(child_pid, 0)
else:
# this is necessary because os._exit doesn't unwind the stack,
# so coverage doesn't get to automatically stop and save
# coverage information.
try:
import coverage

cov = coverage.Coverage.current()
# the following pragmas are necessary because if coverage:
# - isn't running, then it can't record the branch not
# taken
# - isn't installed, then it can't record the ImportError

if cov: # pragma: no branch
cov.stop()
cov.save()
except ImportError: # pragma: no cover
pass

os._exit(0) # pragma: no cover # coverage was stopped above.
else: # pragma: no cover # coverage is shut down by os._exit(0)
# we would *want* to allow coverage to take a snapshot here. check
# git blame for how to do that. however, that times out for some
# reason when having `tests/` in `source` for coverage.py.
os._exit(0)
4 changes: 3 additions & 1 deletion src/trio/_core/_thread_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ def start_thread_soon(
THREAD_CACHE.start_thread_soon(fn, deliver, name)


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