Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/source/contributing/conventions/test-coverage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ Running the Tests
``purge_modules``, which re-imported the package before every test and dominated
the suite's time (:issue:`1065`). Both live in :file:`tests/_support.py`; pass
``restore=True`` when the class must leave :data:`sys.modules` as it found it.

A class whose tests each need their own import purges in ``setUp`` instead of
calling the helper, and says why in a comment there: ``ConstEnumRegisterFallbackTests``
in :file:`tests/const/test_const_enum_builtin_parity.py` does, because a lookup in
one test grows the registries' tables the next one reads. Calling the helper and
then purging the whole package, later in ``setUp`` or in ``tearDown``, throws the
class's import away while reading as if it kept it;
:file:`tests/project/test_per_class_import_guard.py` fails on that (:issue:`1538`).
* **Check ordering under plain unittest.** :file:`tests/conftest.py` heals cross-module
import pollution after every test, so pytest alone cannot see it (:issue:`981`).
:file:`util/run_unittest_leg.py` runs one :file:`tests/` subdirectory, then the
Expand Down
4 changes: 2 additions & 2 deletions tests/protocols/transport/test_tcp_http_dispatch_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import unittest
import warnings

from tests._support import purge_modules, time_limit
from tests._support import reimport_once_per_class, time_limit

RUNTIME_DEPS = ('tbtrim', 'aenum', 'chardet', 'dictdumper')
HAS_RUNTIME = all(importlib.util.find_spec(name) is not None for name in RUNTIME_DEPS)
Expand All @@ -50,7 +50,7 @@ class TCPHTTPDispatchTests(unittest.TestCase):
"""TCP's port-80/8080 entries point at the proxy, and behave like it."""

def setUp(self) -> None:
purge_modules(['pcapkit'])
reimport_once_per_class(self)

def test_tcp_binds_the_http_proxy_on_both_http_ports(self) -> None:
"""Ports 80 and 8080 resolve to ``application.http``, not ``application.httpv1``.
Expand Down
Loading