summaryrefslogtreecommitdiff
path: root/test/test_oddball.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2011-04-27 09:49:23 -0400
committerNed Batchelder <ned@nedbatchelder.com>2011-04-27 09:49:23 -0400
commite91c97da931e54b27a838106d25d6ae5529256ae (patch)
tree352b9857bd6fbee4f6f07dfd80a85b8d5b286a3c /test/test_oddball.py
parentf1d4dcbe9e5b8b8b335521f6aa806f8438fde917 (diff)
parenta243a6a2b34eb9ef5cba3346796160e06ba77930 (diff)
downloadpython-coveragepy-git-e91c97da931e54b27a838106d25d6ae5529256ae.tar.gz
Merge bug_123 work into default.
Diffstat (limited to 'test/test_oddball.py')
-rw-r--r--test/test_oddball.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/test_oddball.py b/test/test_oddball.py
index e94e2bad..859648fa 100644
--- a/test/test_oddball.py
+++ b/test/test_oddball.py
@@ -348,3 +348,37 @@ if sys.version_info >= (2, 5):
doctest.testmod(sys.modules[__name__]) # we're not __main__ :(
''',
[1,11,12,14,16,17], "")
+
+
+if hasattr(sys, 'gettrace'):
+ class GettraceTest(CoverageTest):
+ """Tests that we work properly with `sys.gettrace()`."""
+ def test_round_trip(self):
+ self.check_coverage('''\
+ import sys
+ def foo(n):
+ return 3*n
+ def bar(n):
+ return 5*n
+ a = foo(6)
+ sys.settrace(sys.gettrace())
+ a = bar(8)
+ ''',
+ [1,2,3,4,5,6,7,8], "")
+
+ def test_multi_layers(self):
+ self.check_coverage('''\
+ import sys
+ def level1():
+ a = 3
+ level2()
+ b = 5
+ def level2():
+ c = 7
+ sys.settrace(sys.gettrace())
+ d = 9
+ e = 10
+ level1()
+ f = 12
+ ''',
+ [1,2,3,4,5,6,7,8,9,10,11,12], "")