ansible-core/allow-python3.11.patch
2022-06-18 13:06:04 -05:00

43 lines
1.9 KiB
Diff

diff --git a/test/lib/ansible_test/_util/target/common/constants.py b/test/lib/ansible_test/_util/target/common/constants.py
index fdaa9e5..e1136cc 100644
--- a/test/lib/ansible_test/_util/target/common/constants.py
+++ b/test/lib/ansible_test/_util/target/common/constants.py
@@ -17,4 +17,5 @@ CONTROLLER_PYTHON_VERSIONS = (
'3.8',
'3.9',
'3.10',
+ '3.11',
)
diff --git a/test/units/module_utils/urls/test_fetch_url.py b/test/units/module_utils/urls/test_fetch_url.py
index 4869bb0..94f2e1b 100644
--- a/test/units/module_utils/urls/test_fetch_url.py
+++ b/test/units/module_utils/urls/test_fetch_url.py
@@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
import socket
+import sys
from ansible.module_utils.six import StringIO
from ansible.module_utils.six.moves.http_cookiejar import Cookie
@@ -133,9 +134,16 @@ def test_fetch_url_cookies(mocker, fake_ansible_module):
r, info = fetch_url(fake_ansible_module, 'http://ansible.com/')
assert info['cookies'] == {'Baz': 'qux', 'Foo': 'bar'}
- # Python sorts cookies in order of most specific (ie. longest) path first
- # items with the same path are reversed from response order
- assert info['cookies_string'] == 'Baz=qux; Foo=bar'
+
+ if sys.version_info < (3, 11):
+ # Python sorts cookies in order of most specific (ie. longest) path first
+ # items with the same path are reversed from response order
+ assert info['cookies_string'] == 'Baz=qux; Foo=bar'
+ else:
+ # Python 3.11 and later preserve the Set-Cookie order.
+ # See: https://github.com/python/cpython/pull/22745/
+ assert info['cookies_string'] == 'Foo=bar; Baz=qux'
+
# The key here has a `-` as opposed to what we see in the `uri` module that converts to `_`
# Note: this is response order, which differs from cookies_string
assert info['set-cookie'] == 'Foo=bar, Baz=qux'