Skip to content

Commit c064edf

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

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,15 @@ def test_Request_open_username(urlopen_mock, install_opener_mock):
192192
if isinstance(handler, expected_handlers):
193193
found_handlers.append(handler)
194194
assert len(found_handlers) == 2
195-
assert found_handlers[0].passwd.passwd[None] == {(('ansible.com', '/'),): ('user', None)}
195+
196+
expected = ('user', None)
197+
result = found_handlers[0].passwd.passwd[None]
198+
199+
assert (
200+
# see https://github.com/python/cpython/issues/155694
201+
result == {(('ansible.com', '/'),): expected} or # before fix
202+
result == {((None, 'ansible.com', '/'),): expected} # after fix
203+
)
196204

197205

198206
@pytest.mark.parametrize('url, expected', (
@@ -215,7 +223,14 @@ def test_Request_open_username_in_url(url, expected, urlopen_mock, install_opene
215223
for handler in handlers:
216224
if isinstance(handler, expected_handlers):
217225
found_handlers.append(handler)
218-
assert found_handlers[0].passwd.passwd[None] == {(('ansible.com', '/'),): expected}
226+
227+
result = found_handlers[0].passwd.passwd[None]
228+
229+
assert (
230+
# see https://github.com/python/cpython/issues/155694
231+
result == {(('ansible.com', '/'),): expected} or # before fix
232+
result == {((None, 'ansible.com', '/'),): expected} # after fix
233+
)
219234

220235

221236
def test_Request_open_username_force_basic(urlopen_mock, install_opener_mock):

0 commit comments

Comments
 (0)