diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-09-21 18:23:54 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-09-21 18:23:54 -0400 |
commit | eff5f72064a0577fd0b61a634c4196271dc19308 (patch) | |
tree | 94bf6f45e9a042d9075590a6c9f884b294c2e575 | |
parent | eb307693feb754f483e10e34a10d4540d1f01627 (diff) | |
download | python-coveragepy-git-eff5f72064a0577fd0b61a634c4196271dc19308.tar.gz |
2.7.8 changed how xmlcharrefreplace handles surrogates.
-rw-r--r-- | tests/farm/html/run_unicode.py | 14 | ||||
-rw-r--r-- | tests/test_farm.py | 19 |
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'>"ʎd˙ǝbɐɹǝʌoɔ"</span>", ) -if sys.maxunicode == 65535: - contains("html_unicode/unicode.html", - "<span class='str'>"db40,dd00: x��"</span>", - ) -else: - contains("html_unicode/unicode.html", - "<span class='str'>"db40,dd00: x󠄀"</span>", - ) +contains_any("html_unicode/unicode.html", + "<span class='str'>"db40,dd00: x��"</span>", + "<span class='str'>"db40,dd00: x󠄀"</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. |