summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2012-05-11 23:00:34 -0400
committerNed Batchelder <ned@nedbatchelder.com>2012-05-11 23:00:34 -0400
commit3a67982794e40043e51449e1d40b07258ef8b932 (patch)
treee281ee6e4adb321ebfe8ff16b89417e46ceb00e4
parent63c509ca06a76cfff093ebd0806c2f04cc30f238 (diff)
downloadpython-coveragepy-git-3a67982794e40043e51449e1d40b07258ef8b932.tar.gz
Add a test case for bug #179.
-rw-r--r--test/farm/html/run_bom.py21
-rw-r--r--test/farm/html/run_isolatin1.py2
-rw-r--r--test/farm/html/src/bom.py11
3 files changed, 33 insertions, 1 deletions
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",
+ "<span class='str'>&quot;3&#215;4 = 12, &#247;2 = 6&#177;0&quot;</span>",
+ )
+
+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