summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2014-05-15 09:21:29 -0400
committerNed Batchelder <ned@nedbatchelder.com>2014-05-15 09:21:29 -0400
commitf373746d5f19532c2fc690313fc13be0641eb0f6 (patch)
tree8573d2005368e3f68f1a8d2392678ea21451e7a1 /tests
parentdcfafdac94a31a755b958d6f47ffd09e38ea9833 (diff)
downloadpython-coveragepy-git-f373746d5f19532c2fc690313fc13be0641eb0f6.tar.gz
Run tests with warnings on, and fix some warnings
Diffstat (limited to 'tests')
-rw-r--r--tests/backtest.py4
-rw-r--r--tests/test_farm.py16
2 files changed, 14 insertions, 6 deletions
diff --git a/tests/backtest.py b/tests/backtest.py
index 89a25536..7b47ff19 100644
--- a/tests/backtest.py
+++ b/tests/backtest.py
@@ -46,4 +46,6 @@ try:
except NameError:
def execfile(filename, globs):
"""A Python 3 implementation of execfile."""
- exec(compile(open(filename).read(), filename, 'exec'), globs)
+ with open(filename) as fobj:
+ code = fobj.read()
+ exec(compile(code, filename, 'exec'), globs)
diff --git a/tests/test_farm.py b/tests/test_farm.py
index 261ce4d0..2310e7cc 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.
@@ -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)