Merge pull request #7990 from bluetech/xunit-quadratic-3
unittest: fix quadratic behavior in collection of unittests using setUpClass/setup_method
This commit is contained in:
commit
3adece9fb7
|
@ -0,0 +1,13 @@
|
||||||
|
from unittest import TestCase # noqa: F401
|
||||||
|
|
||||||
|
for i in range(15000):
|
||||||
|
exec(
|
||||||
|
f"""
|
||||||
|
class Test{i}(TestCase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls): pass
|
||||||
|
def test_1(self): pass
|
||||||
|
def test_2(self): pass
|
||||||
|
def test_3(self): pass
|
||||||
|
"""
|
||||||
|
)
|
|
@ -119,7 +119,12 @@ def _make_xunit_fixture(
|
||||||
if setup is None and teardown is None:
|
if setup is None and teardown is None:
|
||||||
return 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]:
|
def fixture(self, request: FixtureRequest) -> Generator[None, None, None]:
|
||||||
if _is_skipped(self):
|
if _is_skipped(self):
|
||||||
reason = self.__unittest_skip_why__
|
reason = self.__unittest_skip_why__
|
||||||
|
|
Loading…
Reference in New Issue