Skip to content

Commit eb54edc

Browse files
committed
tests: Fix cookie test compatibility with Python 3.13.4+
Update the test_get_cookie test to handle changes in LWPCookieJar serialization format introduced in Python 3.13.4+ (see python/cpython#130631). The upstream change removed quotes from domain values in cookie strings. Therefore we now use a regex to match the cookie instead to retain compatibility accross all python versions.
1 parent 5f2b892 commit eb54edc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

osctiny/tests/test_utils.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,14 @@ def test_get_cookie(self, *_):
642642

643643
jar = LWPCookieJar(filename=str(cookie_path))
644644
jar.load()
645-
self.assertEqual(cookie_str, CookieManager.get_cookie(jar=jar))
645+
result = CookieManager.get_cookie(jar=jar)
646+
647+
# Use regex to handle both quoted and unquoted domain formats
648+
# Python 3.13.4+ changed how domains are serialized (no quotes)
649+
expected_pattern = re.escape(cookie_str).replace(
650+
r'domain="\.suse\.de"', r'domain="?\.suse\.de"?'
651+
)
652+
self.assertRegex(result, expected_pattern)
646653

647654

648655
class TestSession(TestCase):

0 commit comments

Comments
 (0)