From 26a49dc5ccb6465a3cdd7a2346c530ce4f88b0dd Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 24 Dec 2015 11:11:37 -0500 Subject: Non-ascii characters work again in config regexes. Fixes #455. --- tests/test_coverage.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tests/test_coverage.py') diff --git a/tests/test_coverage.py b/tests/test_coverage.py index 9e2a444c..02da2032 100644 --- a/tests/test_coverage.py +++ b/tests/test_coverage.py @@ -1,3 +1,4 @@ +# coding: utf-8 # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 # For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt @@ -1128,7 +1129,7 @@ class ExcludeTest(CoverageTest): self.check_coverage("""\ a = 1; b = 2 - if 0: + if len([]): a = 4 # -cc """, [1,3], "", excludes=['-cc']) @@ -1478,6 +1479,17 @@ class ExcludeTest(CoverageTest): """, [8,9], "", excludes=['#pragma: NO COVER']) + def test_excludes_non_ascii(self): + self.check_coverage("""\ + # coding: utf-8 + a = 1; b = 2 + + if len([]): + a = 5 # ✘cover + """, + [2, 4], "", excludes=['✘cover'] + ) + class Py24Test(CoverageTest): """Tests of new syntax in Python 2.4.""" -- cgit v1.2.1 From dd5f8a759843724eaf278a7fa10f6b905d955b34 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 24 Dec 2015 21:42:37 -0500 Subject: if 0: might not do what we want, use a non-constant --- tests/test_coverage.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/test_coverage.py') diff --git a/tests/test_coverage.py b/tests/test_coverage.py index 02da2032..0e5f495a 100644 --- a/tests/test_coverage.py +++ b/tests/test_coverage.py @@ -1150,19 +1150,19 @@ class ExcludeTest(CoverageTest): self.check_coverage("""\ a = 1; b = 2 - if 0: + if len([]): # not-here a = 4 b = 5 c = 6 assert a == 1 and b == 2 """, - [1,7], "", excludes=['if 0:']) + [1,7], "", excludes=['not-here']) def test_excluding_if_but_not_else_suite(self): self.check_coverage("""\ a = 1; b = 2 - if 0: + if len([]): # not-here a = 4 b = 5 c = 6 @@ -1171,7 +1171,7 @@ class ExcludeTest(CoverageTest): b = 9 assert a == 8 and b == 9 """, - [1,8,9,10], "", excludes=['if 0:']) + [1,8,9,10], "", excludes=['not-here']) def test_excluding_else_suite(self): self.check_coverage("""\ @@ -1230,7 +1230,7 @@ class ExcludeTest(CoverageTest): self.check_coverage("""\ def foo(): a = 2 - if 0: x = 3 # no cover + if len([]): x = 3 # no cover b = 4 foo() -- cgit v1.2.1 From 8b110d3a3f7fbddfcbdaa1b090776e0f388a312e Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 25 Dec 2015 07:34:09 -0500 Subject: Change if-0 skips to real skips in the tests --- tests/test_coverage.py | 52 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'tests/test_coverage.py') diff --git a/tests/test_coverage.py b/tests/test_coverage.py index 0e5f495a..ab4faf55 100644 --- a/tests/test_coverage.py +++ b/tests/test_coverage.py @@ -403,35 +403,35 @@ class SimpleStatementTest(CoverageTest): """, [1,2,3,4,5], "4") - if 0: # expected failure + def test_strange_unexecuted_continue(self): # Peephole optimization of jumps to jumps can mean that some statements # never hit the line tracer. The behavior is different in different # versions of Python, so don't run this test: - def test_strange_unexecuted_continue(self): - self.check_coverage("""\ - a = b = c = 0 - for n in range(100): - if n % 2: - if n % 4: - a += 1 - continue # <-- This line may not be hit. - else: - b += 1 - c += 1 - assert a == 50 and b == 50 and c == 50 - - a = b = c = 0 - for n in range(100): - if n % 2: - if n % 3: - a += 1 - continue # <-- This line is always hit. - else: - b += 1 - c += 1 - assert a == 33 and b == 50 and c == 50 - """, - [1,2,3,4,5,6,8,9,10, 12,13,14,15,16,17,19,20,21], "") + self.skip("Expected failure: peephole optimization of jumps to jumps") + self.check_coverage("""\ + a = b = c = 0 + for n in range(100): + if n % 2: + if n % 4: + a += 1 + continue # <-- This line may not be hit. + else: + b += 1 + c += 1 + assert a == 50 and b == 50 and c == 50 + + a = b = c = 0 + for n in range(100): + if n % 2: + if n % 3: + a += 1 + continue # <-- This line is always hit. + else: + b += 1 + c += 1 + assert a == 33 and b == 50 and c == 50 + """, + [1,2,3,4,5,6,8,9,10, 12,13,14,15,16,17,19,20,21], "") def test_import(self): self.check_coverage("""\ -- cgit v1.2.1