diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/farm/html/gold_x_xml/coverage.xml | 3 | ||||
-rw-r--r-- | tests/farm/html/gold_y_xml_branch/coverage.xml | 3 | ||||
-rw-r--r-- | tests/farm/html/run_a_xml_1.py | 6 | ||||
-rw-r--r-- | tests/farm/html/run_a_xml_2.py | 6 | ||||
-rw-r--r-- | tests/farm/html/run_y_xml_branch.py | 6 | ||||
-rw-r--r-- | tests/farm/html/src/coverage.xml | 3 | ||||
-rw-r--r-- | tests/test_farm.py | 19 |
7 files changed, 35 insertions, 11 deletions
diff --git a/tests/farm/html/gold_x_xml/coverage.xml b/tests/farm/html/gold_x_xml/coverage.xml index 912112f2..d5a8c442 100644 --- a/tests/farm/html/gold_x_xml/coverage.xml +++ b/tests/farm/html/gold_x_xml/coverage.xml @@ -3,6 +3,9 @@ SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-03.dtd'>
<coverage branch-rate="0" line-rate="0.6667" timestamp="1253972570431" version="3.1b1">
<!-- Generated by coverage.py: http://nedbatchelder.com/code/coverage/VER -->
+ <sources>
+ <source></source>
+ </sources>
<packages>
<package branch-rate="0" complexity="0" line-rate="0.6667" name="">
<classes>
diff --git a/tests/farm/html/gold_y_xml_branch/coverage.xml b/tests/farm/html/gold_y_xml_branch/coverage.xml index ecbe0073..86e9e73c 100644 --- a/tests/farm/html/gold_y_xml_branch/coverage.xml +++ b/tests/farm/html/gold_y_xml_branch/coverage.xml @@ -3,6 +3,9 @@ SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-03.dtd'>
<coverage branch-rate="0.5" line-rate="0.8" timestamp="1259288252325" version="3.2b4">
<!-- Generated by coverage.py: http://nedbatchelder.com/code/coverage/VER -->
+ <sources>
+ <source></source>
+ </sources>
<packages>
<package branch-rate="0.5" complexity="0" line-rate="0.8" name="">
<classes>
diff --git a/tests/farm/html/run_a_xml_1.py b/tests/farm/html/run_a_xml_1.py index 3d187023..04fdfd4b 100644 --- a/tests/farm/html/run_a_xml_1.py +++ b/tests/farm/html/run_a_xml_1.py @@ -1,3 +1,5 @@ +relative_path = None + def html_it(): """Run coverage and make an XML report for a.""" import coverage @@ -6,6 +8,8 @@ def html_it(): import a # pragma: nested cov.stop() # pragma: nested cov.xml_report(a, outfile="../xml_1/coverage.xml") + global relative_path + relative_path = cov.file_locator.relative_dir.rstrip('/') import os if not os.path.exists("xml_1"): @@ -16,6 +20,8 @@ runfunc(html_it, rundir="src") compare("gold_x_xml", "xml_1", scrubs=[ (r' timestamp="\d+"', ' timestamp="TIMESTAMP"'), (r' version="[-.\w]+"', ' version="VERSION"'), + (r'<source>(\s)*?(.*)(\s)*?</source>', + '<source>%s</source>' % relative_path), (r'/code/coverage/?[-.\w]*', '/code/coverage/VER'), ]) clean("xml_1") diff --git a/tests/farm/html/run_a_xml_2.py b/tests/farm/html/run_a_xml_2.py index 53691ead..205ca453 100644 --- a/tests/farm/html/run_a_xml_2.py +++ b/tests/farm/html/run_a_xml_2.py @@ -1,3 +1,5 @@ +relative_path = None + def html_it(): """Run coverage and make an XML report for a.""" import coverage @@ -6,6 +8,8 @@ def html_it(): import a # pragma: nested cov.stop() # pragma: nested cov.xml_report(a) + global relative_path + relative_path = cov.file_locator.relative_dir.rstrip('/') import os if not os.path.exists("xml_2"): @@ -16,6 +20,8 @@ runfunc(html_it, rundir="src") compare("gold_x_xml", "xml_2", scrubs=[ (r' timestamp="\d+"', ' timestamp="TIMESTAMP"'), (r' version="[-.\w]+"', ' version="VERSION"'), + (r'<source>(\s)*?(.*)(\s)*?</source>', + '<source>%s</source>' % relative_path), (r'/code/coverage/?[-.\w]*', '/code/coverage/VER'), ]) clean("xml_2") diff --git a/tests/farm/html/run_y_xml_branch.py b/tests/farm/html/run_y_xml_branch.py index 88a2e44e..18d7f7d9 100644 --- a/tests/farm/html/run_y_xml_branch.py +++ b/tests/farm/html/run_y_xml_branch.py @@ -1,3 +1,5 @@ +relative_path = None + def xml_it(): """Run coverage and make an XML report for y.""" import coverage @@ -6,6 +8,8 @@ def xml_it(): import y # pragma: nested cov.stop() # pragma: nested cov.xml_report(y, outfile="../xml_branch/coverage.xml") + global relative_path + relative_path = cov.file_locator.relative_dir.rstrip('/') import os if not os.path.exists("xml_branch"): @@ -16,6 +20,8 @@ runfunc(xml_it, rundir="src") compare("gold_y_xml_branch", "xml_branch", scrubs=[ (r' timestamp="\d+"', ' timestamp="TIMESTAMP"'), (r' version="[-.\w]+"', ' version="VERSION"'), + (r'<source>(\s)*?(.*)(\s)*?</source>', + '<source>%s</source>' % relative_path), (r'/code/coverage/?[-.\w]*', '/code/coverage/VER'), ]) clean("xml_branch") diff --git a/tests/farm/html/src/coverage.xml b/tests/farm/html/src/coverage.xml index 128cf750..e20cdaec 100644 --- a/tests/farm/html/src/coverage.xml +++ b/tests/farm/html/src/coverage.xml @@ -3,6 +3,9 @@ SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-03.dtd'>
<coverage branch-rate="0.0" line-rate="0.666666666667" timestamp="1263087779313" version="3.3a1">
<!-- Generated by coverage.py: http://nedbatchelder.com/code/coverage -->
+ <sources>
+ <source></source>
+ </sources>
<packages>
<package branch-rate="0.0" complexity="0.0" line-rate="0.666666666667" name="">
<classes>
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. |