summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/farm/html/run_unicode.py14
-rw-r--r--tests/test_farm.py19
2 files changed, 22 insertions, 11 deletions
diff --git a/tests/farm/html/run_unicode.py b/tests/farm/html/run_unicode.py
index cef26ee5..c8cb6c50 100644
--- a/tests/farm/html/run_unicode.py
+++ b/tests/farm/html/run_unicode.py
@@ -1,5 +1,3 @@
-import sys
-
def html_it():
"""Run coverage and make an HTML report for unicode.py."""
import coverage
@@ -18,13 +16,9 @@ contains("html_unicode/unicode.html",
"<span class='str'>&quot;&#654;d&#729;&#477;b&#592;&#633;&#477;&#652;o&#596;&quot;</span>",
)
-if sys.maxunicode == 65535:
- contains("html_unicode/unicode.html",
- "<span class='str'>&quot;db40,dd00: x&#56128;&#56576;&quot;</span>",
- )
-else:
- contains("html_unicode/unicode.html",
- "<span class='str'>&quot;db40,dd00: x&#917760;&quot;</span>",
- )
+contains_any("html_unicode/unicode.html",
+ "<span class='str'>&quot;db40,dd00: x&#56128;&#56576;&quot;</span>",
+ "<span class='str'>&quot;db40,dd00: x&#917760;&quot;</span>",
+ )
clean("html_unicode")
diff --git a/tests/test_farm.py b/tests/test_farm.py
index b2ea3697..47f9b7b7 100644
--- a/tests/test_farm.py
+++ b/tests/test_farm.py
@@ -79,7 +79,8 @@ class FarmTestCase(object):
# Prepare a dictionary of globals for the run.py files to use.
fns = """
- copy run runfunc compare contains doesnt_contain clean skip
+ copy run runfunc clean skip
+ compare contains contains_any doesnt_contain
""".split()
if self.clean_only:
glo = dict((fn, self.noop) for fn in fns)
@@ -304,6 +305,22 @@ class FarmTestCase(object):
for s in strlist:
assert s in text, "Missing content in %s: %r" % (filename, s)
+ def contains_any(self, filename, *strlist):
+ """Check that the file contains at least one of a list of strings.
+
+ An assert will be raised if none of the arguments in `strlist` is in
+ `filename`.
+
+ """
+ with open(filename, "r") as fobj:
+ text = fobj.read()
+ for s in strlist:
+ if s in text:
+ return
+ assert False, "Missing content in %s: %r [1 of %d]" % (
+ filename, strlist[0], len(strlist),
+ )
+
def doesnt_contain(self, filename, *strlist):
"""Check that the file contains none of a list of strings.