Seen locally. The with self.subTest(): is not safe to call from multiple threads concurrently because subTest modifies self._subtest, so you might end up with the wrong or None subtest in the call to testPartExecutor.
test_lru_cache_threaded3 (test.test_functools.TestLRUC.test_lru_cache_threaded3) ... Warning -- Uncaught thread exception: AttributeError
Exception in thread Thread-21 (test):
Traceback (most recent call last):
File "/raid/sgross/cpython/Lib/threading.py", line 1054, in _bootstrap_inner
self.run()
~~~~~~~~^^
File "/raid/sgross/cpython/Lib/threading.py", line 996, in run
self._target(*self._args, **self._kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/raid/sgross/cpython/Lib/test/test_functools.py", line 1937, in test
with self.subTest(thread=i):
~~~~~~~~~~~~^^^^^^^^^^
File "/raid/sgross/cpython/Lib/contextlib.py", line 148, in __exit__
next(self.gen)
~~~~^^^^^^^^^^
File "/raid/sgross/cpython/Lib/unittest/case.py", line 555, in subTest
with self._outcome.testPartExecutor(self._subtest, subTest=True):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/raid/sgross/cpython/Lib/contextlib.py", line 148, in __exit__
next(self.gen)
~~~~^^^^^^^^^^
File "/raid/sgross/cpython/Lib/unittest/case.py", line 81, in testPartExecutor
self.result.addSubTest(test_case.test_case, test_case, None)
^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'test_case'
ok
Bug report
Seen locally. The
with self.subTest():is not safe to call from multiple threads concurrently becausesubTestmodifiesself._subtest, so you might end up with the wrong orNonesubtest in the call totestPartExecutor.cpython/Lib/test/test_functools.py
Lines 1930 to 1942 in d372472
cpython/Lib/unittest/case.py
Lines 553 to 566 in d372472
Linked PRs