aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_trace.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_trace.py')
-rw-r--r--Lib/test/test_trace.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
index 2292ad6155d..461d1d8e6a4 100644
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_trace.py
@@ -1,6 +1,6 @@
import os
import sys
-from test.test_support import (run_unittest, TESTFN, rmtree, unlink,
+from test.support import (run_unittest, TESTFN, rmtree, unlink,
captured_stdout)
import unittest
@@ -163,7 +163,9 @@ class TestLineCounts(unittest.TestCase):
firstlineno_called = get_firstlineno(traced_doubler)
expected = {
(self.my_py_filename, firstlineno_calling + 1): 1,
- (self.my_py_filename, firstlineno_calling + 2): 11,
+ # List compehentions work differently in 3.x, so the count
+ # below changed compared to 2.x.
+ (self.my_py_filename, firstlineno_calling + 2): 12,
(self.my_py_filename, firstlineno_calling + 3): 1,
(self.my_py_filename, firstlineno_called + 1): 10,
}
@@ -328,10 +330,25 @@ class TestCoverage(unittest.TestCase):
lines, cov, module = line.split()[:3]
coverage[module] = (int(lines), int(cov[:-1]))
# XXX This is needed to run regrtest.py as a script
- modname = trace.fullmodname(sys.modules[modname].__file__)
+ modname = trace._fullmodname(sys.modules[modname].__file__)
self.assertIn(modname, coverage)
self.assertEqual(coverage[modname], (5, 100))
+### Tests that don't mess with sys.settrace and can be traced
+### themselves TODO: Skip tests that do mess with sys.settrace when
+### regrtest is invoked with -T option.
+class Test_Ignore(unittest.TestCase):
+ def test_ignored(self):
+ jn = os.path.join
+ ignore = trace._Ignore(['x', 'y.z'], [jn('foo', 'bar')])
+ self.assertTrue(ignore.names('x.py', 'x'))
+ self.assertFalse(ignore.names('xy.py', 'xy'))
+ self.assertFalse(ignore.names('y.py', 'y'))
+ self.assertTrue(ignore.names(jn('foo', 'bar', 'baz.py'), 'baz'))
+ self.assertFalse(ignore.names(jn('bar', 'z.py'), 'z'))
+ # Matched before.
+ self.assertTrue(ignore.names(jn('bar', 'baz.py'), 'baz'))
+
def test_main():
run_unittest(__name__)