From 3a67982794e40043e51449e1d40b07258ef8b932 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 11 May 2012 23:00:34 -0400 Subject: Add a test case for bug #179. --- test/farm/html/run_bom.py | 21 +++++++++++++++++++++ test/farm/html/run_isolatin1.py | 2 +- test/farm/html/src/bom.py | 11 +++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 test/farm/html/run_bom.py create mode 100644 test/farm/html/src/bom.py (limited to 'test') diff --git a/test/farm/html/run_bom.py b/test/farm/html/run_bom.py new file mode 100644 index 00000000..918ad784 --- /dev/null +++ b/test/farm/html/run_bom.py @@ -0,0 +1,21 @@ +import sys + +def html_it(): + """Run coverage and make an HTML report for bom.py.""" + import coverage + cov = coverage.coverage() + cov.start() + import bom + cov.stop() + cov.html_report(bom, directory="../html_bom") + +runfunc(html_it, rundir="src") + +# HTML files will change often. Check that the sizes are reasonable, +# and check that certain key strings are in the output. +compare("gold_bom", "html_bom", size_within=10, file_pattern="*.html") +contains("html_bom/bom.html", + ""3×4 = 12, ÷2 = 6±0"", + ) + +clean("html_bom") diff --git a/test/farm/html/run_isolatin1.py b/test/farm/html/run_isolatin1.py index 3d4b23c5..9f4b8690 100644 --- a/test/farm/html/run_isolatin1.py +++ b/test/farm/html/run_isolatin1.py @@ -1,7 +1,7 @@ import sys def html_it(): - """Run coverage and make an HTML report for unicode.py.""" + """Run coverage and make an HTML report for isolatin1.py.""" import coverage cov = coverage.coverage() cov.start() diff --git a/test/farm/html/src/bom.py b/test/farm/html/src/bom.py new file mode 100644 index 00000000..2db8b717 --- /dev/null +++ b/test/farm/html/src/bom.py @@ -0,0 +1,11 @@ +# A python source file in utf-8, with BOM +math = "3×4 = 12, ÷2 = 6±0" + +import sys + +if sys.version_info >= (3, 0): + assert len(math) == 18 + assert len(math.encode('utf-8')) == 21 +else: + assert len(math) == 21 + assert len(math.decode('utf-8')) == 18 -- cgit v1.2.1