summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-07-12 13:41:54 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-07-12 13:41:54 -0400
commitc2f0d6406cf6d18f35f1a0de6025a017d3382974 (patch)
tree04b6596a86a29c4e7c0112f2b08340c0af39cb7f /tests
parentf5c5a8f5ca51e8aa17749692d46d6933a1fee663 (diff)
downloadpython-coveragepy-git-c2f0d6406cf6d18f35f1a0de6025a017d3382974.tar.gz
More reworking of the data api
Diffstat (limited to 'tests')
-rw-r--r--tests/test_arcs.py2
-rw-r--r--tests/test_data.py3
-rw-r--r--tests/test_oddball.py20
3 files changed, 12 insertions, 13 deletions
diff --git a/tests/test_arcs.py b/tests/test_arcs.py
index 63120616..c84c5441 100644
--- a/tests/test_arcs.py
+++ b/tests/test_arcs.py
@@ -761,5 +761,5 @@ class LineDataTest(CoverageTest):
self.start_import_stop(cov, "fun1")
data = cov.get_data()
- fun1_lines = data.line_data()[abs_file("fun1.py")]
+ fun1_lines = data.line_data(abs_file("fun1.py"))
self.assertEqual(fun1_lines, [1, 2, 5])
diff --git a/tests/test_data.py b/tests/test_data.py
index c89bbea7..ff4d0c0a 100644
--- a/tests/test_data.py
+++ b/tests/test_data.py
@@ -107,10 +107,11 @@ class DataTest(DataTestHelpers, CoverageTest):
covdata1 = CoverageData()
covdata1.add_line_data(DATA_1)
covdatafiles.write(covdata1)
+
covdata1.erase()
self.assert_summary(covdata1, {})
- covdatafiles.erase()
+ covdatafiles.erase()
covdata2 = CoverageData()
covdatafiles.read(covdata2)
self.assert_summary(covdata2, {})
diff --git a/tests/test_oddball.py b/tests/test_oddball.py
index 268624f7..5288f022 100644
--- a/tests/test_oddball.py
+++ b/tests/test_oddball.py
@@ -1,9 +1,9 @@
"""Oddball cases for testing coverage.py"""
-import os
import sys
import coverage
+from coverage.files import abs_file
from tests.coveragetest import CoverageTest
from tests import osinfo
@@ -307,7 +307,8 @@ class ExceptionTest(CoverageTest):
for callnames, lines_expected in runs:
# Make the list of functions we'll call for this test.
- calls = [getattr(sys.modules[cn], cn) for cn in callnames.split()]
+ callnames = callnames.split()
+ calls = [getattr(sys.modules[cn], cn) for cn in callnames]
cov = coverage.coverage()
cov.start()
@@ -318,16 +319,13 @@ class ExceptionTest(CoverageTest):
# Clean the line data and compare to expected results.
# The filenames are absolute, so keep just the base.
- data = cov.get_data()
- lines = data.line_data()
clean_lines = {}
- for f, llist in lines.items():
- # f is a path to a Python module, so we drop the '.py' to get
- # a callname.
- basename = os.path.basename(f)
- assert basename.endswith(".py")
- if basename[:-3] in callnames:
- clean_lines[basename] = llist
+ data = cov.get_data()
+ for callname in callnames:
+ filename = callname + ".py"
+ lines = data.line_data(abs_file(filename))
+ clean_lines[filename] = sorted(lines)
+
self.assertEqual(clean_lines, lines_expected)