Skip to content

Commit fd3e5ed

Browse files
committed
Update tests for new MultiDomainBasicAuth signature
1 parent 7a55e13 commit fd3e5ed

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

tests/unit/test_network_auth.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ def test_get_credentials_uses_cached_credentials_only_username() -> None:
9191

9292

9393
def test_get_index_url_credentials() -> None:
94-
auth = MultiDomainBasicAuth(index_urls=["http://foo:[email protected]/path"])
95-
get = functools.partial(
96-
auth._get_new_credentials, allow_netrc=False, allow_keyring=False
94+
auth = MultiDomainBasicAuth(
95+
index_urls=["http://foo:[email protected]/path"], allow_keyring=False
9796
)
97+
get = functools.partial(auth._get_new_credentials, allow_netrc=False)
9898

9999
# Check resolution of indexes
100100
assert get("http://example.com/path/path2") == ("foo", "bar")
@@ -139,9 +139,11 @@ def test_keyring_get_password(
139139
) -> None:
140140
keyring = KeyringModuleV1()
141141
monkeypatch.setattr("pip._internal.network.auth.keyring", keyring)
142-
auth = MultiDomainBasicAuth(index_urls=["http://example.com/path2"])
142+
auth = MultiDomainBasicAuth(
143+
index_urls=["http://example.com/path2"], allow_keyring=True
144+
)
143145

144-
actual = auth._get_new_credentials(url, allow_netrc=False, allow_keyring=True)
146+
actual = auth._get_new_credentials(url, allow_netrc=False)
145147
assert actual == expect
146148

147149

@@ -185,10 +187,10 @@ def test_keyring_get_password_username_in_index(
185187
) -> None:
186188
keyring = KeyringModuleV1()
187189
monkeypatch.setattr("pip._internal.network.auth.keyring", keyring)
188-
auth = MultiDomainBasicAuth(index_urls=["http://[email protected]/path2"])
189-
get = functools.partial(
190-
auth._get_new_credentials, allow_netrc=False, allow_keyring=True
190+
auth = MultiDomainBasicAuth(
191+
index_urls=["http://[email protected]/path2"], allow_keyring=True
191192
)
193+
get = functools.partial(auth._get_new_credentials, allow_netrc=False)
192194

193195
assert get("http://example.com/path2/path3") == ("user", "user!url")
194196
assert get("http://example.com/path4/path1") == (None, None)
@@ -294,12 +296,12 @@ def test_keyring_get_credential(
294296
monkeypatch: pytest.MonkeyPatch, url: str, expect: str
295297
) -> None:
296298
monkeypatch.setattr(pip._internal.network.auth, "keyring", KeyringModuleV2())
297-
auth = MultiDomainBasicAuth(index_urls=["http://example.com/path2"])
298-
299-
assert (
300-
auth._get_new_credentials(url, allow_netrc=False, allow_keyring=True) == expect
299+
auth = MultiDomainBasicAuth(
300+
index_urls=["http://example.com/path2"], allow_keyring=True
301301
)
302302

303+
assert auth._get_new_credentials(url, allow_netrc=False) == expect
304+
303305

304306
class KeyringModuleBroken:
305307
"""Represents the current supported API of keyring, but broken"""
@@ -316,12 +318,10 @@ def test_broken_keyring_disables_keyring(monkeypatch: pytest.MonkeyPatch) -> Non
316318
keyring_broken = KeyringModuleBroken()
317319
monkeypatch.setattr(pip._internal.network.auth, "keyring", keyring_broken)
318320

319-
auth = MultiDomainBasicAuth(index_urls=["http://example.com/"])
321+
auth = MultiDomainBasicAuth(index_urls=["http://example.com/"], allow_keyring=True)
320322

321323
assert keyring_broken._call_count == 0
322324
for i in range(5):
323325
url = "http://example.com/path" + str(i)
324-
assert auth._get_new_credentials(
325-
url, allow_netrc=False, allow_keyring=True
326-
) == (None, None)
326+
assert auth._get_new_credentials(url, allow_netrc=False) == (None, None)
327327
assert keyring_broken._call_count == 1

0 commit comments

Comments
 (0)