diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-11-28 18:02:57 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-11-28 18:02:57 -0500 |
commit | 8daa8515ccd83355669b0a70ffa74201ec69f6de (patch) | |
tree | 14cb71eb03c6d6086508752b02f9b3f2d13e1da5 /tests | |
parent | 1f1133bd842b61d5e28ddb29ae68cea8ab3a6a7c (diff) | |
download | python-coveragepy-8daa8515ccd83355669b0a70ffa74201ec69f6de.tar.gz |
Make sure check_include isn't called more than once per file.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_plugins.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_plugins.py b/tests/test_plugins.py index b94d077..874cf52 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -160,6 +160,7 @@ if not C_TRACER: """) cov = coverage.Coverage() + snoop_on_callbacks(cov) cov.config["run:plugins"] = ["tests.plugin1"] # Import the python file, executing it. @@ -192,12 +193,16 @@ if not C_TRACER: from render import helper, render assert render("foo_7.html", 4) == "[foo_7.html @ 4]" + # Render foo_7.html again to trigger the callback snoopers. + render("foo_7.html", 4) + assert helper(42) == 43 assert render("bar_4.html", 2) == "[bar_4.html @ 2]" assert helper(76) == 77 """) cov = coverage.Coverage() + snoop_on_callbacks(cov) cov.config["run:plugins"] = ["tests.plugin2"] self.start_import_stop(cov, "caller") @@ -211,3 +216,21 @@ if not C_TRACER: _, statements, missing, _ = cov.analysis("bar_4.html") self.assertEqual(statements, [1,2,3,4]) self.assertEqual(missing, [1,4]) + + +def snoop_on_callbacks(cov): + cov_should_trace = cov._should_trace + should_trace_filenames = set() + def snoop_should_trace(filename, frame): + assert filename not in should_trace_filenames + should_trace_filenames.add(filename) + return cov_should_trace(filename, frame) + cov._should_trace = snoop_should_trace + + cov_check_include = cov._check_include_omit_etc + check_include_filenames = set() + def snoop_check_include_filenames(filename, frame): + assert filename not in check_include_filenames + check_include_filenames.add(filename) + return cov_check_include(filename, frame) + cov._check_include_omit_etc = snoop_check_include_filenames |