diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2016-01-01 13:38:06 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2016-01-01 13:38:06 -0500 |
commit | d6e221c8058259460cadfe62d5ca1bb0d93822cc (patch) | |
tree | ab1e46401f52ca0c24107243fef45c52f4163a22 | |
parent | 9edd625b8fdb09b5494471d460eba11148104e28 (diff) | |
download | python-coveragepy-git-d6e221c8058259460cadfe62d5ca1bb0d93822cc.tar.gz |
test_arcs now passes for all Python versions
--HG--
branch : ast-branch
-rw-r--r-- | coverage/parser.py | 7 | ||||
-rw-r--r-- | tests/test_arcs.py | 6 |
2 files changed, 11 insertions, 2 deletions
diff --git a/coverage/parser.py b/coverage/parser.py index b2618921..33480924 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -388,7 +388,12 @@ class AstArcAnalyzer(object): def is_constant_expr(self, node): """Is this a compile-time constant?""" node_name = node.__class__.__name__ - return node_name in ["NameConstant", "Num"] + if node_name in ["NameConstant", "Num"]: + return True + elif node_name == "Name": + if env.PY3 and node.id in ["True", "False", "None"]: + return True + return False # tests to write: # TODO: while EXPR: diff --git a/tests/test_arcs.py b/tests/test_arcs.py index a9533e78..ea79d495 100644 --- a/tests/test_arcs.py +++ b/tests/test_arcs.py @@ -342,7 +342,7 @@ class LoopArcTest(CoverageTest): """, arcz=arcz, arcz_missing="", arcz_unpredicted="") - def test_other_comprehensions(self): + def test_generator_expression(self): # Generator expression: self.check_coverage("""\ o = ((1,2), (3,4)) @@ -354,6 +354,10 @@ class LoopArcTest(CoverageTest): arcz=".1 .2 2-2 12 23 34 45 53 3.", arcz_missing="", arcz_unpredicted="" ) + + def test_other_comprehensions(self): + if env.PYVERSION < (2, 7): + self.skip("Don't have set or dict comprehensions before 2.7") # Set comprehension: self.check_coverage("""\ o = ((1,2), (3,4)) |