Skip to content

Commit c0c66e7

Browse files
authored
[stable-2.14] Update module_utils urls unit tests (#87483) (#87489)
Update the tests to work on newer Python versions which contain fixes for python/cpython#155694. (cherry picked from commit 5ba4572)
1 parent a34d220 commit c0c66e7

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

‎test/units/module_utils/urls/test_Request.py‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,15 @@ def test_Request_open_username(urlopen_mock, install_opener_mock):
207207
if isinstance(handler, expected_handlers):
208208
found_handlers.append(handler)
209209
assert len(found_handlers) == 2
210-
assert found_handlers[0].passwd.passwd[None] == {(('ansible.com', '/'),): ('user', None)}
210+
211+
expected = ('user', None)
212+
result = found_handlers[0].passwd.passwd[None]
213+
214+
assert (
215+
# see https://github.com/python/cpython/issues/155694
216+
result == {(('ansible.com', '/'),): expected} or # before fix
217+
result == {((None, 'ansible.com', '/'),): expected} # after fix
218+
)
211219

212220

213221
def test_Request_open_username_in_url(urlopen_mock, install_opener_mock):
@@ -225,7 +233,15 @@ def test_Request_open_username_in_url(urlopen_mock, install_opener_mock):
225233
for handler in handlers:
226234
if isinstance(handler, expected_handlers):
227235
found_handlers.append(handler)
228-
assert found_handlers[0].passwd.passwd[None] == {(('ansible.com', '/'),): ('user2', '')}
236+
237+
expected = ('user2', '')
238+
result = found_handlers[0].passwd.passwd[None]
239+
240+
assert (
241+
# see https://github.com/python/cpython/issues/155694
242+
result == {(('ansible.com', '/'),): expected} or # before fix
243+
result == {((None, 'ansible.com', '/'),): expected} # after fix
244+
)
229245

230246

231247
def test_Request_open_username_force_basic(urlopen_mock, install_opener_mock):

0 commit comments

Comments
 (0)