diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2013-12-14 14:17:56 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2013-12-14 14:17:56 -0500 |
commit | a0141e1324bccc4dffc1054de013826874497762 (patch) | |
tree | 139ddf1046dbe083f80699fb866d1b7395ecc3de /tests/test_coverage.py | |
parent | 124e04f9077cc2b76f9eb28e5f8b7c49a26c4452 (diff) | |
download | python-coveragepy-a0141e1324bccc4dffc1054de013826874497762.tar.gz |
No need for paren-less exec any more.
Diffstat (limited to 'tests/test_coverage.py')
-rw-r--r-- | tests/test_coverage.py | 91 |
1 files changed, 29 insertions, 62 deletions
diff --git a/tests/test_coverage.py b/tests/test_coverage.py index 6eb37e2..0cb33dc 100644 --- a/tests/test_coverage.py +++ b/tests/test_coverage.py @@ -497,68 +497,35 @@ class SimpleStatementTest(CoverageTest): """, [1,2,3,4,5], "") - if sys.version_info < (3, 0): - # In Python 2.x, exec is a statement. - def test_exec(self): - self.check_coverage("""\ - a = b = c = 1 - exec "a = 2" - exec ("b = " + - "c = " + - "2") - assert a == 2 and b == 2 and c == 2 - """, - [1,2,3,6], "") - self.check_coverage("""\ - vars = {'a': 1, 'b': 1, 'c': 1} - exec "a = 2" in vars - exec ("b = " + - "c = " + - "2") in vars - assert vars['a'] == 2 and vars['b'] == 2 and vars['c'] == 2 - """, - [1,2,3,6], "") - self.check_coverage("""\ - globs = {} - locs = {'a': 1, 'b': 1, 'c': 1} - exec "a = 2" in globs, locs - exec ("b = " + - "c = " + - "2") in globs, locs - assert locs['a'] == 2 and locs['b'] == 2 and locs['c'] == 2 - """, - [1,2,3,4,7], "") - else: - # In Python 3.x, exec is a function. - def test_exec(self): - self.check_coverage("""\ - a = b = c = 1 - exec("a = 2") - exec("b = " + - "c = " + - "2") - assert a == 2 and b == 2 and c == 2 - """, - [1,2,3,6], "") - self.check_coverage("""\ - vars = {'a': 1, 'b': 1, 'c': 1} - exec("a = 2", vars) - exec("b = " + - "c = " + - "2", vars) - assert vars['a'] == 2 and vars['b'] == 2 and vars['c'] == 2 - """, - [1,2,3,6], "") - self.check_coverage("""\ - globs = {} - locs = {'a': 1, 'b': 1, 'c': 1} - exec("a = 2", globs, locs) - exec("b = " + - "c = " + - "2", globs, locs) - assert locs['a'] == 2 and locs['b'] == 2 and locs['c'] == 2 - """, - [1,2,3,4,7], "") + def test_exec(self): + self.check_coverage("""\ + a = b = c = 1 + exec("a = 2") + exec("b = " + + "c = " + + "2") + assert a == 2 and b == 2 and c == 2 + """, + [1,2,3,6], "") + self.check_coverage("""\ + vars = {'a': 1, 'b': 1, 'c': 1} + exec("a = 2", vars) + exec("b = " + + "c = " + + "2", vars) + assert vars['a'] == 2 and vars['b'] == 2 and vars['c'] == 2 + """, + [1,2,3,6], "") + self.check_coverage("""\ + globs = {} + locs = {'a': 1, 'b': 1, 'c': 1} + exec("a = 2", globs, locs) + exec("b = " + + "c = " + + "2", globs, locs) + assert locs['a'] == 2 and locs['b'] == 2 and locs['c'] == 2 + """, + [1,2,3,4,7], "") def test_extra_doc_string(self): self.check_coverage("""\ |