unittest: fix quadratic behavior in collection of unittests using setUpClass/setup_method

This is similar to 50114d4731876dae; I missed that unittest does the
same thing.
This commit is contained in:
Ran Benita
2020-11-01 15:09:32 +02:00
parent a95da7a425
commit 489f6f4499
2 changed files with 19 additions and 1 deletions

View File

@@ -119,7 +119,12 @@ def _make_xunit_fixture(
if setup is None and teardown is None:
return None
@pytest.fixture(scope=scope, autouse=True)
@pytest.fixture(
scope=scope,
autouse=True,
# Use a unique name to speed up lookup.
name=f"unittest_{setup_name}_fixture_{obj.__qualname__}",
)
def fixture(self, request: FixtureRequest) -> Generator[None, None, None]:
if _is_skipped(self):
reason = self.__unittest_skip_why__