diff --git a/pyproject.toml b/pyproject.toml index bec87cfef..1478e556d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 diff --git a/src/trio/_core/_tests/test_thread_cache.py b/src/trio/_core/_tests/test_thread_cache.py index a308befb6..3abdd59e4 100644 --- a/src/trio/_core/_tests/test_thread_cache.py +++ b/src/trio/_core/_tests/test_thread_cache.py @@ -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) diff --git a/src/trio/_core/_thread_cache.py b/src/trio/_core/_thread_cache.py index 44820e771..c2b2315bd 100644 --- a/src/trio/_core/_thread_cache.py +++ b/src/trio/_core/_thread_cache.py @@ -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