diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-11-24 20:30:53 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-11-24 20:30:53 -0500 |
commit | b0a0f00a433d7c3467d07ce7cea4cfbaaa6ae49e (patch) | |
tree | 34c48b1b92baf9ae9e64282ec38e793e2c61423d /tests/test_plugins.py | |
parent | 4354d6ee80c81d390052c15092c7c51f2318f2f6 (diff) | |
download | python-coveragepy-git-b0a0f00a433d7c3467d07ce7cea4cfbaaa6ae49e.tar.gz |
Change how dynamic source filenames work in plugins.
Diffstat (limited to 'tests/test_plugins.py')
-rw-r--r-- | tests/test_plugins.py | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 7c4986a5..f2658998 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -137,7 +137,11 @@ class PluginTest(CoverageTest): cov.start() cov.stop() - def test_importing_myself(self): + +class FileTracerTest(CoverageTest): + """Tests of plugins that implement file_tracer.""" + + def test_plugin1(self): if sys.platform == 'win32': raise SkipTest("Plugin stuff is jank on windows.. fixing soon...") @@ -162,3 +166,34 @@ class PluginTest(CoverageTest): self.assertEqual(missing, []) _, statements, _, _ = cov.analysis("/src/try_ABC.zz") self.assertEqual(statements, [105, 106, 107, 205, 206, 207]) + + def test_plugin2(self): + self.make_file("render.py", """\ + def render(filename, linenum): + fiddle_around = 1 # vamp until ready + return "[{0} @ {1}]".format(filename, linenum) + """) + self.make_file("caller.py", """\ + from render import render + + assert render("foo.html", 17) == "[foo.html @ 17]" + assert render("bar.html", 23) == "[bar.html @ 23]" + """) + + cov = coverage.Coverage() + cov.config["run:plugins"] = ["tests.plugin2"] + cov.config["run:debug"] = ["trace"] + + self.start_import_stop(cov, "caller") + + print(self.stderr()) + cov._harvest_data() + print(cov.data.line_data()) + + return # TODO: finish this test + + _, statements, missing, _ = cov.analysis("simple.py") + self.assertEqual(statements, [1,2,3]) + self.assertEqual(missing, []) + _, statements, _, _ = cov.analysis("/src/try_ABC.zz") + self.assertEqual(statements, [105, 106, 107, 205, 206, 207]) |