Fixes #10541: regrtest -T is broken
* makes test_trace tests restore the tracefunc after they run * write_results() in trace module will not terminate if lnotab cannot be found.
This commit is contained in:
parent
15c6ed5239
commit
f026dae130
|
@ -10,7 +10,6 @@ from trace import CoverageResults, Trace
|
|||
|
||||
from test.tracedmodules import testmod
|
||||
|
||||
|
||||
#------------------------------- Utilities -----------------------------------#
|
||||
|
||||
def fix_ext_py(filename):
|
||||
|
@ -224,6 +223,11 @@ class TestFuncs(unittest.TestCase):
|
|||
self.addCleanup(sys.settrace, sys.gettrace())
|
||||
self.tracer = Trace(count=0, trace=0, countfuncs=1)
|
||||
self.filemod = my_file_and_modname()
|
||||
self._saved_tracefunc = sys.gettrace()
|
||||
|
||||
def tearDown(self):
|
||||
if self._saved_tracefunc is not None:
|
||||
sys.settrace(self._saved_tracefunc)
|
||||
|
||||
def test_simple_caller(self):
|
||||
self.tracer.runfunc(traced_func_simple_caller, 1)
|
||||
|
|
|
@ -326,7 +326,7 @@ class CoverageResults:
|
|||
lnotab = _find_executable_linenos(filename)
|
||||
else:
|
||||
lnotab = {}
|
||||
|
||||
if lnotab:
|
||||
source = linecache.getlines(filename)
|
||||
coverpath = os.path.join(dir, modulename + ".cover")
|
||||
with open(filename, 'rb') as fp:
|
||||
|
@ -337,6 +337,7 @@ class CoverageResults:
|
|||
percent = int(100 * n_hits / n_lines)
|
||||
sums[modulename] = n_lines, percent, modulename, filename
|
||||
|
||||
|
||||
if summary and sums:
|
||||
print("lines cov% module (path)")
|
||||
for m in sorted(sums):
|
||||
|
|
Loading…
Reference in New Issue