summaryrefslogtreecommitdiff
path: root/tests/test_farm.py
diff options
context:
space:
mode:
authorDanny Allen <me@dannya.com>2014-08-11 16:13:06 +0100
committerDanny Allen <me@dannya.com>2014-08-11 16:13:06 +0100
commite38016c499921dd7bf5919a699a76305a1936129 (patch)
tree07a4125732561f2489dfb6b75a339cfef46d80d4 /tests/test_farm.py
parentc81183f614ca982cd2ed93ac8e6e76610d162202 (diff)
parentee5ea987f8978d91c1ef189fe4f334511ddf6215 (diff)
downloadpython-coveragepy-git-e38016c499921dd7bf5919a699a76305a1936129.tar.gz
Merged ned/coveragepy into default
Diffstat (limited to 'tests/test_farm.py')
-rw-r--r--tests/test_farm.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/tests/test_farm.py b/tests/test_farm.py
index 261ce4d0..b2ea3697 100644
--- a/tests/test_farm.py
+++ b/tests/test_farm.py
@@ -15,6 +15,10 @@ def test_farm(clean_only=False):
yield (case,)
+# "rU" was deprecated in 3.4
+READ_MODE = "rU" if sys.version_info < (3, 4) else "r"
+
+
class FarmTestCase(object):
"""A test case from the farm tree.
@@ -22,8 +26,8 @@ class FarmTestCase(object):
copy("src", "out")
run('''
- coverage -x white.py
- coverage -a white.py
+ coverage run white.py
+ coverage annotate white.py
''', rundir="out")
compare("out", "gold", "*,cover")
clean("out")
@@ -258,9 +262,9 @@ class FarmTestCase(object):
# ourselves.
text_diff = []
for f in diff_files:
- with open(os.path.join(dir1, f), "rU") as fobj:
+ with open(os.path.join(dir1, f), READ_MODE) as fobj:
left = fobj.read()
- with open(os.path.join(dir2, f), "rU") as fobj:
+ with open(os.path.join(dir2, f), READ_MODE) as fobj:
right = fobj.read()
if scrubs:
left = self._scrub(left, scrubs)
@@ -280,7 +284,7 @@ class FarmTestCase(object):
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
+ `scrubs` is a list of (find, replace) pairs of regexes that are used on
`strdata`. A string is returned.
"""
@@ -295,7 +299,8 @@ class FarmTestCase(object):
missing in `filename`.
"""
- text = open(filename, "r").read()
+ with open(filename, "r") as fobj:
+ text = fobj.read()
for s in strlist:
assert s in text, "Missing content in %s: %r" % (filename, s)
@@ -306,7 +311,8 @@ class FarmTestCase(object):
`filename`.
"""
- text = open(filename, "r").read()
+ with open(filename, "r") as fobj:
+ text = fobj.read()
for s in strlist:
assert s not in text, "Forbidden content in %s: %r" % (filename, s)