diff options
-rw-r--r-- | coverage/parser.py | 2 | ||||
-rw-r--r-- | tests/coveragetest.py | 9 | ||||
-rw-r--r-- | tests/modules/zerocoverage/__init__.py | 1 | ||||
-rw-r--r-- | tests/modules/zerocoverage/__main__.py | 1 | ||||
-rw-r--r-- | tests/modules/zerocoverage/zero.py | 3 | ||||
-rw-r--r-- | tests/test_arcs.py | 17 |
6 files changed, 16 insertions, 17 deletions
diff --git a/coverage/parser.py b/coverage/parser.py index e2708519..e027b41b 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -646,7 +646,7 @@ class AstArcAnalyzer(object): if node_name in ["NameConstant", "Num"]: return "Num" elif node_name == "Name": - if (( env.PY3 or env.PYVERSION >= (2, 7)) and + if ((env.PY3 or env.PYVERSION >= (2, 7)) and node.id in ["True", "False", "None"]): return "Name" return None diff --git a/tests/coveragetest.py b/tests/coveragetest.py index 4a917192..707652fb 100644 --- a/tests/coveragetest.py +++ b/tests/coveragetest.py @@ -397,8 +397,8 @@ class CoverageTest( # Add our test modules directory to PYTHONPATH. I'm sure there's too # much path munging here, but... - testmods = self.nice_file(self.here(), 'tests/modules') - zipfile = self.nice_file(self.here(), 'tests/zipmods.zip') + testmods = self.nice_file(self.working_root(), 'tests/modules') + zipfile = self.nice_file(self.working_root(), 'tests/zipmods.zip') pypath = os.getenv('PYTHONPATH', '') if pypath: pypath += os.pathsep @@ -409,9 +409,10 @@ class CoverageTest( print(self.last_command_output) return self.last_command_status, self.last_command_output - def here(self): + def working_root(self): + """Where is the root of the coverage.py working tree?""" return os.path.dirname(self.nice_file(coverage.__file__, "..")) - + def report_from_command(self, cmd): """Return the report from the `cmd`, with some convenience added.""" report = self.run_command(cmd).replace('\\', '/') diff --git a/tests/modules/zerocoverage/__init__.py b/tests/modules/zerocoverage/__init__.py deleted file mode 100644 index 0acf595e..00000000 --- a/tests/modules/zerocoverage/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# no empty file to please hg diff --git a/tests/modules/zerocoverage/__main__.py b/tests/modules/zerocoverage/__main__.py deleted file mode 100644 index 91082160..00000000 --- a/tests/modules/zerocoverage/__main__.py +++ /dev/null @@ -1 +0,0 @@ -print('done') diff --git a/tests/modules/zerocoverage/zero.py b/tests/modules/zerocoverage/zero.py deleted file mode 100644 index 6ae283f1..00000000 --- a/tests/modules/zerocoverage/zero.py +++ /dev/null @@ -1,3 +0,0 @@ -def method(self): - while True: - return 1 diff --git a/tests/test_arcs.py b/tests/test_arcs.py index 50751826..22323bcd 100644 --- a/tests/test_arcs.py +++ b/tests/test_arcs.py @@ -252,7 +252,7 @@ class LoopArcTest(CoverageTest): """, arcz=".1 12 23 34 45 36 63 57 7.", ) - # With "while True", 2.x thinks it's computation, + # 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." @@ -273,17 +273,20 @@ class LoopArcTest(CoverageTest): ) def test_zero_coverage_and_regexps(self): - # https://bitbucket.org/ned/coveragepy/issue/502 + # 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.make_file("main.py", "print('done')") + self.make_file("zero.py", """\ + def method(self): + while True: + return 1 + """) + out = self.run_command("coverage run --branch --source=. main.py") 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]) + self.assertIn("zero.py 3 3 0 0 0% 1-3", squeezed[3]) def test_bug_496_continue_in_constant_while(self): # https://bitbucket.org/ned/coveragepy/issue/496 |