summaryrefslogtreecommitdiff
path: root/tests/test_process.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2013-03-10 10:30:07 -0400
committerNed Batchelder <ned@nedbatchelder.com>2013-03-10 10:30:07 -0400
commitd05b0617fad4d7972c6b8a1c671b4a00c37f1208 (patch)
tree55bd3840f02bc1d091f3824eafbb92a3c85ed1ef /tests/test_process.py
parent145329fd982ea56bf1237ca0bea264cd9db9bc7b (diff)
downloadpython-coveragepy-git-d05b0617fad4d7972c6b8a1c671b4a00c37f1208.tar.gz
Don't issue spurious warnings about the trace function changing. Fixes #164
Diffstat (limited to 'tests/test_process.py')
-rw-r--r--tests/test_process.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test_process.py b/tests/test_process.py
index f3d6c56d..8e31bd18 100644
--- a/tests/test_process.py
+++ b/tests/test_process.py
@@ -430,6 +430,39 @@ class ProcessTest(CoverageTest):
self.assertNotIn("warning", out)
self.assertNotIn("Exception", out)
+ def test_warnings_trace_function_changed_with_threads(self):
+ # https://bitbucket.org/ned/coveragepy/issue/164
+ self.make_file("bug164.py", """\
+ import threading
+ import time
+
+ class MyThread (threading.Thread):
+ def run(self):
+ print("Hello")
+
+ thr = MyThread()
+ thr.start()
+ thr.join()
+ """)
+ out = self.run_command("coverage run --timid bug164.py")
+
+ self.assertIn("Hello\n", out)
+ self.assertNotIn("warning", out)
+
+ def test_warning_trace_function_changed(self):
+ self.make_file("settrace.py", """\
+ import sys
+ print("Hello")
+ sys.settrace(None)
+ print("Goodbye")
+ """)
+ out = self.run_command("coverage run --timid settrace.py")
+ self.assertIn("Hello\n", out)
+ self.assertIn("Goodbye\n", out)
+
+ if hasattr(sys, "gettrace"):
+ self.assertIn("Trace function changed", out)
+
if sys.version_info >= (3, 0): # This only works on 3.x for now.
# It only works with the C tracer,
c_tracer = os.getenv('COVERAGE_TEST_TRACER', 'c') == 'c'