diff options
author | loic@dachary.org <loic@dachary.org> | 2016-12-15 18:33:16 +0100 |
---|---|---|
committer | loic@dachary.org <loic@dachary.org> | 2016-12-15 18:33:16 +0100 |
commit | 5c131498d140e172c5471929be4f30c65a200547 (patch) | |
tree | a02534e2f0b9269dea5aca1d8bde889ab859189e /tests/test_arcs.py | |
parent | 88207df5fa00861bf42f0993b23ce541817b72dd (diff) | |
download | python-coveragepy-git-5c131498d140e172c5471929be4f30c65a200547.tar.gz |
also use AST for while constants in python-2.7 #502
The node.id is set to False, True or None is python-2.7: there is no
reason to only check for it with python-3. It is more reliable than
using the DEFAULT_PARTIAL_ALWAYS regexps on source lines.
close #502
--HG--
branch : issue-502-7
Diffstat (limited to 'tests/test_arcs.py')
-rw-r--r-- | tests/test_arcs.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/test_arcs.py b/tests/test_arcs.py index 2fd033b8..50751826 100644 --- a/tests/test_arcs.py +++ b/tests/test_arcs.py @@ -252,10 +252,12 @@ class LoopArcTest(CoverageTest): """, arcz=".1 12 23 34 45 36 63 57 7.", ) - # With "while True", 2.x thinks it's computation, 3.x thinks it's - # constant. + # With "while True", 2.x thinks it's computation, + # 2.7+ and 3.x thinks it's constant. if env.PY3: arcz = ".1 12 23 34 45 36 63 57 7." + elif env.PYVERSION >= (2, 7): + arcz = ".1 12 23 34 45 36 62 57 7." else: arcz = ".1 12 23 27 34 45 36 62 57 7." self.check_coverage("""\ @@ -270,10 +272,25 @@ class LoopArcTest(CoverageTest): arcz=arcz, ) + def test_zero_coverage_and_regexps(self): + # https://bitbucket.org/ned/coveragepy/issue/502 + if env.PYVERSION < (2, 7): + self.skipTest("No node.id before 2.7") + self.clean_local_file_imports() + zerocoverage_path = self.nice_file(self.here(), 'tests/modules/zerocoverage') + out = self.run_command( + "coverage run --branch --source {0} -m zerocoverage".format(zerocoverage_path)) + self.assertEqual(out, 'done\n') + report = self.report_from_command("coverage report -m") + squeezed = self.squeezed_lines(report) + self.assertIn("zero.py 3 3 0 0 0% 1-3", squeezed[4]) + def test_bug_496_continue_in_constant_while(self): # https://bitbucket.org/ned/coveragepy/issue/496 if env.PY3: arcz = ".1 12 23 34 45 53 46 6." + elif env.PYVERSION >= (2, 7): + arcz = ".1 12 23 34 45 52 46 6." else: arcz = ".1 12 2-1 23 34 45 52 46 6." self.check_coverage("""\ |