From eff5f72064a0577fd0b61a634c4196271dc19308 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 21 Sep 2014 18:23:54 -0400 Subject: 2.7.8 changed how xmlcharrefreplace handles surrogates. --- tests/farm/html/run_unicode.py | 14 ++++---------- tests/test_farm.py | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 11 deletions(-) (limited to 'tests') 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", ""ʎd˙ǝbɐɹǝʌoɔ"", ) -if sys.maxunicode == 65535: - contains("html_unicode/unicode.html", - ""db40,dd00: x��"", - ) -else: - contains("html_unicode/unicode.html", - ""db40,dd00: x󠄀"", - ) +contains_any("html_unicode/unicode.html", + ""db40,dd00: x��"", + ""db40,dd00: x󠄀"", + ) 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. -- cgit v1.2.1