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 | 67dda6193ac439de034a6c1236800500be8c7193 (patch) | |
tree | b27835ad36823fbbe22fbcf7bf7f134c68b58100 /tests/test_farm.py | |
parent | b45f28a29661a60b0a45efafd6e875ceb34146b7 (diff) | |
download | python-coveragepy-git-67dda6193ac439de034a6c1236800500be8c7193.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 c86983e5..65016b34 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. |