Skip to content

Commit 5645fb8

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

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
@@ -208,7 +208,15 @@ def test_Request_open_username(urlopen_mock, install_opener_mock):
208208
if isinstance(handler, expected_handlers):
209209
found_handlers.append(handler)
210210
assert len(found_handlers) == 2
211-
assert found_handlers[0].passwd.passwd[None] == {(('ansible.com', '/'),): ('user', None)}
211+
212+
expected = ('user', None)
213+
result = found_handlers[0].passwd.passwd[None]
214+
215+
assert (
216+
# see https://github.com/python/cpython/issues/155694
217+
result == {(('ansible.com', '/'),): expected} or # before fix
218+
result == {((None, 'ansible.com', '/'),): expected} # after fix
219+
)
212220

213221

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

231247

232248
def test_Request_open_username_force_basic(urlopen_mock, install_opener_mock):

0 commit comments

Comments
 (0)