mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
Issue #10990: Prevent tests from clobbering a set trace function.
Many tests simply didn't care if they unset a pre-existing trace function. This made test coverage impossible. This patch fixes various tests to put back any pre-existing trace function. It also introduces test.support.no_tracing as a decorator which will temporarily unset the trace function for tests which simply fail otherwise. Thanks to Kristian Vlaardingerbroek for helping to find the cause of various trace function unsets.
This commit is contained in:
parent
4709ec0686
commit
31f5929c1e
15 changed files with 283 additions and 221 deletions
|
|
@ -7,7 +7,7 @@
|
|||
import weakref
|
||||
|
||||
from test.support import (TESTFN, unlink, run_unittest, captured_output,
|
||||
gc_collect, cpython_only)
|
||||
gc_collect, cpython_only, no_tracing)
|
||||
|
||||
# XXX This is not really enough, each *operation* should be tested!
|
||||
|
||||
|
|
@ -388,6 +388,7 @@ def __init__(self, fancy_arg):
|
|||
x = DerivedException(fancy_arg=42)
|
||||
self.assertEqual(x.fancy_arg, 42)
|
||||
|
||||
@no_tracing
|
||||
def testInfiniteRecursion(self):
|
||||
def f():
|
||||
return f()
|
||||
|
|
@ -631,6 +632,7 @@ def testUnicodeChangeAttributes(self):
|
|||
u.start = 1000
|
||||
self.assertEqual(str(u), "can't translate characters in position 1000-4: 965230951443685724997")
|
||||
|
||||
@no_tracing
|
||||
def test_badisinstance(self):
|
||||
# Bug #2542: if issubclass(e, MyException) raises an exception,
|
||||
# it should be ignored
|
||||
|
|
@ -741,6 +743,7 @@ def inner():
|
|||
self.fail("MemoryError not raised")
|
||||
self.assertEqual(wr(), None)
|
||||
|
||||
@no_tracing
|
||||
def test_recursion_error_cleanup(self):
|
||||
# Same test as above, but with "recursion exceeded" errors
|
||||
class C:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue