File: 0005-Change-test-to-not-rely-on-order-of-cookie-iteration.patch

package info (click to toggle)
python-mechanize 1%3A0.4.8%2Bpypi-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,612 kB
  • sloc: python: 16,644; makefile: 11
file content (35 lines) | stat: -rw-r--r-- 1,274 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From: Kovid Goyal <kovid@kovidgoyal.net>
Date: Tue, 24 May 2022 18:09:16 +0530
Subject: Change test to not rely on order of cookie iteration

python 3.11 iterates in add order, earlier pythons iterate in domain
sorted order

Fix #74
---
 test/test_cookies.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/test/test_cookies.py b/test/test_cookies.py
index 20055d8..ec0c2ff 100644
--- a/test/test_cookies.py
+++ b/test/test_cookies.py
@@ -1022,13 +1022,12 @@ class CookieTests(unittest.TestCase):
             "www.acme.com"
         ]
         paths = ["/", "/", "/", "/blah", "/blah/"]
-
+        expected = set(zip(versions, names, domains, paths))
         # sequential iteration
-        for i in range(4):
-            for c, expected in zip(cs, zip(versions, names, domains, paths)):
-                # assert isinstance(c, Cookie)
-                self.assertEqual((c.version, c.name, c.domain, c.path), expected)
-
+        # python 3.11 iterates in add order, earlier pythons iterate in domain
+        # sorted order
+        actual = {(c.version, c.name, c.domain, c.path) for c in cs}
+        self.assertEqual(expected, actual)
         self.assertRaises(IndexError, lambda cs=cs: cs[5])
 
     def test_parse_ns_headers(self):