Message297525
So the problem is occurring because a single `Test` class is being instantiated with three different tests here in datetimetester.py:
for name in ZoneInfo.zonenames():
Test = type('ZoneInfoTest[%s]' % name, (ZoneInfoTest,), {})
Test.zonename = name
for method in dir(Test):
if method.startswith('test_'):
tests.append(Test(method))
here: https://github.com/python/cpython/blob/master/Lib/test/datetimetester.py#L4853
The `Test` class which is being dynamically created is being instantiated with the test methods: test_folds, test_gaps, test_system_transitions and is being appended to tests. This makes that class to appear thrice in `test_classes` in `test_datetime.py`:
elif issubclass(cls, unittest.TestSuite):
suit = cls()
test_classes.extend(type(test) for test in suit)
here: https://github.com/python/cpython/blob/master/Lib/test/test_datetime.py#L34
Hence, the class gets `_Pure` and `_Fast` appended to its name thrice and gets executed thrice, making the tests take 3 times as long to run.
This is confirmed by changing the code to the following:
for name in ZoneInfo.zonenames():
Test = type('ZoneInfoTest[%s]' % name, (ZoneInfoTest,), {})
Test.zonename = name
tests.append(Test())
# for method in dir(Test):
# if method.startswith('test_'):
# tests.append(Test(method))
However, I'm not sure what implications this has w.r.t. unittests and the advanced cases.
The other way to fix it is to create a set out of the classes, as suggested in PR #2534.
~
ut |
|
Date |
User |
Action |
Args |
2017-07-02 19:37:07 | musically_ut | set | recipients:
+ musically_ut, belopolsky, ned.deily, serhiy.storchaka |
2017-07-02 19:37:07 | musically_ut | set | messageid: <1499024227.65.0.448751462579.issue30822@psf.upfronthosting.co.za> |
2017-07-02 19:37:07 | musically_ut | link | issue30822 messages |
2017-07-02 19:37:07 | musically_ut | create | |
|