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