diff --git a/Lib/test/libregrtest/tsan.py b/Lib/test/libregrtest/tsan.py index f1f8c8bde920ae..b41bea996638f3 100644 --- a/Lib/test/libregrtest/tsan.py +++ b/Lib/test/libregrtest/tsan.py @@ -36,6 +36,7 @@ # the regression test runner with the `--parallel-threads` option enabled. TSAN_PARALLEL_TESTS = [ 'test_abc', + 'test_exceptions', 'test_hashlib', ] diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 0a50912ff0ea8c..c1a00dd09e4a43 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -2923,7 +2923,7 @@ def force_colorized(func): def wrapper(*args, **kwargs): with force_color(True): return func(*args, **kwargs) - return wrapper + return thread_unsafe(wrapper) # modifying the environment is thread-unsafe def force_not_colorized(func): diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 6f212d2f91efb1..84588701e528a7 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -60,6 +60,7 @@ def raise_catch(self, exc, excname): self.assertEqual(buf1, buf2) self.assertEqual(exc.__name__, excname) + @support.thread_unsafe("TESTFN") def testRaising(self): self.raise_catch(AttributeError, "AttributeError") self.assertRaises(AttributeError, getattr, sys, "undefined_attribute") @@ -1411,6 +1412,7 @@ def __str__(self): self.assertRaises(TypeError, str, exc) @no_tracing + @support.thread_unsafe("captures stderr") def test_badisinstance(self): # Bug #2542: if issubclass(e, MyException) raises an exception, # it should be ignored @@ -1536,6 +1538,7 @@ def test_recursion_normalizing_infinite_exception(self): self.assertIn(b'Done.', out) + @support.thread_unsafe("uses sys.setrecursionlimit") @support.skip_emscripten_stack_overflow() def test_recursion_in_except_handler(self): @@ -1672,6 +1675,7 @@ class C(object): @cpython_only @unittest.skipIf(_testcapi is None, "requires _testcapi") + @support.thread_unsafe("gc_collect()") def test_memory_error_cleanup(self): # Issue #5437: preallocated MemoryError instances should not keep # traceback objects alive. @@ -1721,6 +1725,7 @@ def test_errno_ENOTDIR(self): os.listdir(__file__) self.assertEqual(cm.exception.errno, errno.ENOTDIR, cm.exception) + @support.thread_unsafe("uses catch_unraisable_exception") def test_unraisable(self): # Issue #22836: PyErr_WriteUnraisable() should give sensible reports class BrokenDel: @@ -1740,6 +1745,7 @@ def __del__(self): f"deallocator {obj_repr}") self.assertIsNotNone(cm.unraisable.exc_traceback) + @support.thread_unsafe("captures stderr") def test_unhandled(self): # Check for sensible reporting of unhandled exceptions for exc_type in (ValueError, BrokenStrException): @@ -1839,6 +1845,7 @@ def g(): next(i) @unittest.skipUnless(__debug__, "Won't work if __debug__ is False") + @support.thread_unsafe("modifies global AssertionError") def test_assert_shadowing(self): # Shadowing AssertionError would cause the assert statement to # misbehave. @@ -1963,6 +1970,7 @@ def test_name_error_has_name(self): except NameError as exc: self.assertEqual("bluch", exc.name) + @support.thread_unsafe("captures stderr") def test_issue45826(self): # regression test for bpo-45826 def f(): @@ -1979,6 +1987,7 @@ def f(): self.assertIn("aab", err.getvalue()) + @support.thread_unsafe("captures stderr") def test_issue45826_focused(self): def f(): try: @@ -2099,6 +2108,7 @@ def test_reset_attributes(self): self.assertEqual(exc.name, None) self.assertEqual(exc.path, None) + @support.thread_unsafe("check_warnings") def test_non_str_argument(self): # Issue #15778 with check_warnings(('', BytesWarning), quiet=True): @@ -2425,6 +2435,7 @@ class MySyntaxError(SyntaxError): ^^^^^ """, err.getvalue()) + @support.thread_unsafe("TESTFN") def test_encodings(self): self.addCleanup(unlink, TESTFN) source = (