OLD | NEW |
(Empty) | |
| 1 # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 |
| 2 # For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt |
| 3 |
| 4 # Test that the --timid command line argument properly swaps the tracer |
| 5 # function for a simpler one. |
| 6 # |
| 7 # This is complicated by the fact that the tests are run twice for each |
| 8 # version: once with a compiled C-based trace function, and once without |
| 9 # it, to also test the Python trace function. So this test has to examine |
| 10 # an environment variable set in igor.py to know whether to expect to see |
| 11 # the C trace function or not. |
| 12 |
| 13 import os |
| 14 |
| 15 # When meta-coverage testing, this test doesn't work, because it finds |
| 16 # coverage.py's own trace function. |
| 17 if os.environ.get('COVERAGE_COVERAGE', ''): |
| 18 skip("Can't test timid during coverage measurement.") |
| 19 |
| 20 copy("src", "out") |
| 21 run(""" |
| 22 python showtrace.py none |
| 23 coverage run showtrace.py regular |
| 24 coverage run --timid showtrace.py timid |
| 25 """, rundir="out", outfile="showtraceout.txt") |
| 26 |
| 27 # When running without coverage, no trace function |
| 28 # When running timidly, the trace function is always Python. |
| 29 contains("out/showtraceout.txt", |
| 30 "none None", |
| 31 "timid PyTracer", |
| 32 ) |
| 33 |
| 34 if os.environ.get('COVERAGE_TEST_TRACER', 'c') == 'c': |
| 35 # If the C trace function is being tested, then regular running should have |
| 36 # the C function, which registers itself as f_trace. |
| 37 contains("out/showtraceout.txt", "regular CTracer") |
| 38 else: |
| 39 # If the Python trace function is being tested, then regular running will |
| 40 # also show the Python function. |
| 41 contains("out/showtraceout.txt", "regular PyTracer") |
| 42 |
| 43 clean("out") |
OLD | NEW |