From 068bbc3a6678ca4e4bb99d6b7178c67f4e258ddb Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 26 Jan 2015 22:01:18 -0500 Subject: Give a reasonable warning for a previous assert. Closes #353. --- tests/test_process.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') diff --git a/tests/test_process.py b/tests/test_process.py index a1c853d1..43fdc1bd 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -568,6 +568,31 @@ class ProcessTest(CoverageTest): out = self.run_command("python allok.py") self.assertEqual(out, "No warnings!\n") + def test_run_twice(self): + # https://bitbucket.org/ned/coveragepy/issue/353/40a3-introduces-an-unexpected-third-case + self.make_file("foo.py", """\ + def foo(): + pass + """) + self.make_file("run_twice.py", """\ + import coverage + + for _ in [1, 2]: + inst = coverage.Coverage(source=['foo']) + inst.load() + inst.start() + import foo + inst.stop() + inst.combine() + inst.save() + """) + out = self.run_command("python run_twice.py") + self.assertEqual( + out, + "Coverage.py warning: " + "Module foo was previously imported, but not measured.\n" + ) + class AliasedCommandTest(CoverageTest): """Tests of the version-specific command aliases.""" -- cgit v1.2.1