|
|
2f2215 |
From 32d8c0665ea044f9682a89633d75442d1a4d2dc4 Mon Sep 17 00:00:00 2001
|
|
|
2f2215 |
From: Ned Batchelder <ned@nedbatchelder.com>
|
|
|
2f2215 |
Date: Thu, 5 Dec 2019 16:37:48 -0500
|
|
|
2f2215 |
Subject: [PATCH] Fix the context tests
|
|
|
2f2215 |
|
|
|
2f2215 |
CoverageData.lines() returns a list, but in no guaranteed order.
|
|
|
2f2215 |
Set-ify everything to get the correct comparison.
|
|
|
2f2215 |
---
|
|
|
2f2215 |
tests/test_pytest_cov.py | 6 +++---
|
|
|
2f2215 |
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
|
2f2215 |
|
|
|
2f2215 |
diff --git a/tests/test_pytest_cov.py b/tests/test_pytest_cov.py
|
|
|
2f2215 |
index e79e9aa..3be8278 100644
|
|
|
2f2215 |
--- a/tests/test_pytest_cov.py
|
|
|
2f2215 |
+++ b/tests/test_pytest_cov.py
|
|
|
2f2215 |
@@ -1934,12 +1934,12 @@ def test_cov_and_no_cov(testdir):
|
|
|
2f2215 |
|
|
|
2f2215 |
|
|
|
2f2215 |
def find_labels(text, pattern):
|
|
|
2f2215 |
- all_labels = collections.defaultdict(list)
|
|
|
2f2215 |
+ all_labels = collections.defaultdict(set)
|
|
|
2f2215 |
lines = text.splitlines()
|
|
|
2f2215 |
for lineno, line in enumerate(lines, start=1):
|
|
|
2f2215 |
labels = re.findall(pattern, line)
|
|
|
2f2215 |
for label in labels:
|
|
|
2f2215 |
- all_labels[label].append(lineno)
|
|
|
2f2215 |
+ all_labels[label].add(lineno)
|
|
|
2f2215 |
return all_labels
|
|
|
2f2215 |
|
|
|
2f2215 |
|
|
|
2f2215 |
@@ -2007,7 +2007,7 @@ def test_contexts(testdir, opts):
|
|
|
2f2215 |
if context == '':
|
|
|
2f2215 |
continue
|
|
|
2f2215 |
data.set_query_context(context)
|
|
|
2f2215 |
- actual = data.lines(test_context_path)
|
|
|
2f2215 |
+ actual = set(data.lines(test_context_path))
|
|
|
2f2215 |
assert line_data[label] == actual, "Wrong lines for context {!r}".format(context)
|
|
|
2f2215 |
|
|
|
2f2215 |
|