Patch-Source: https://github.com/python-mechanize/mechanize/commit/560839d51e54943890c2d37c0d0854792479cb80 From 560839d51e54943890c2d37c0d0854792479cb80 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 24 May 2022 18:09:16 +0530 Subject: [PATCH] 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 cb03060..ec0c2ff 100644 --- a/test/test_cookies.py +++ b/test/test_cookies.py @@ -1022,18 +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): - i = 0 - for c in cs: - # assert isinstance(c, Cookie) - assert c.version == versions[i] - assert c.name == names[i] - assert c.domain == domains[i] - assert c.path == paths[i] - i = i + 1 - + # 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):