From 64a2ffaaa2739ab0df4db7322e51c3faae7bafdb Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 3 Jun 2011 23:19:10 -0400 Subject: Fix a test involving optimized-away constant if statements, and add a test about them. --- test/farm/html/run_partial.py | 7 ++++++- test/test_coverage.py | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/test/farm/html/run_partial.py b/test/farm/html/run_partial.py index 3fb621a1..0ef8589c 100644 --- a/test/farm/html/run_partial.py +++ b/test/farm/html/run_partial.py @@ -1,3 +1,5 @@ +import sys + def html_it(): """Run coverage and make an HTML report for partial.""" import coverage @@ -21,7 +23,10 @@ contains("html_partial/partial.html", ) contains("html_partial/index.html", "partial", - "100%" ) +if sys.version_info >= (2, 4): + contains("html_partial/index.html", + "100%" + ) clean("html_partial") diff --git a/test/test_coverage.py b/test/test_coverage.py index 7c12b3a7..5da9cb16 100644 --- a/test/test_coverage.py +++ b/test/test_coverage.py @@ -842,6 +842,16 @@ class CompoundStatementTest(CoverageTest): """, [1,2,4,5,7,9,10], "4, 7") + if sys.version_info >= (2, 4): + # In 2.4 and up, constant if's were compiled away. + def test_constant_if(self): + self.check_coverage("""\ + if 1: + a = 2 + assert a == 2 + """, + [2,3], "") + def test_while(self): self.check_coverage("""\ a = 3; b = 0 -- cgit v1.2.1