diff options
author | Stan Hu <stan.hu@aclimalabs.com> | 2014-04-25 06:56:45 -0700 |
---|---|---|
committer | Stan Hu <stan.hu@aclimalabs.com> | 2014-04-25 06:56:45 -0700 |
commit | 7e29b42cc52b30777fac9157387ce23b52909887 (patch) | |
tree | 52737f077b327721e754e1af978a19a76ac3b077 /tests/test_farm.py | |
parent | 78963a9a59c822da64c5643bf6af7d801b89e460 (diff) | |
download | python-coveragepy-7e29b42cc52b30777fac9157387ce23b52909887.tar.gz |
Update tests to handle XML whitespaces differences in Python 2.6. Apply the regexp scrubs to the entire file
instead of individual lines for this to work.
Diffstat (limited to 'tests/test_farm.py')
-rw-r--r-- | tests/test_farm.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/tests/test_farm.py b/tests/test_farm.py index c86983e..65016b3 100644 --- a/tests/test_farm.py +++ b/tests/test_farm.py @@ -256,8 +256,8 @@ class FarmTestCase(object): # ourselves. text_diff = [] for f in diff_files: - left = open(os.path.join(dir1, f), "rU").readlines() - right = open(os.path.join(dir2, f), "rU").readlines() + left = open(os.path.join(dir1, f), "rU").read() + right = open(os.path.join(dir2, f), "rU").read() if scrubs: left = self._scrub(left, scrubs) right = self._scrub(right, scrubs) @@ -271,19 +271,16 @@ class FarmTestCase(object): if not right_extra: assert not right_only, "Files in %s only: %s" % (dir2, right_only) - def _scrub(self, strlist, scrubs): - """Scrub uninteresting data from the strings in `strlist`. + def _scrub(self, strdata, scrubs): + """Scrub uninteresting data from the payload in `strdata`. `scrubs is a list of (find, replace) pairs of regexes that are used on - each string in `strlist`. A list of scrubbed strings is returned. + `strdata`. A string is returned. """ - scrubbed = [] - for s in strlist: - for rgx_find, rgx_replace in scrubs: - s = re.sub(rgx_find, rgx_replace, s) - scrubbed.append(s) - return scrubbed + for rgx_find, rgx_replace in scrubs: + strdata = re.sub(rgx_find, rgx_replace, strdata) + return strdata def contains(self, filename, *strlist): """Check that the file contains all of a list of strings. |