@@ -91,10 +91,10 @@ def test_get_credentials_uses_cached_credentials_only_username() -> None:
91
91
92
92
93
93
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
97
96
)
97
+ get = functools .partial (auth ._get_new_credentials , allow_netrc = False )
98
98
99
99
# Check resolution of indexes
100
100
assert get ("http://example.com/path/path2" ) == ("foo" , "bar" )
@@ -139,9 +139,11 @@ def test_keyring_get_password(
139
139
) -> None :
140
140
keyring = KeyringModuleV1 ()
141
141
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
+ )
143
145
144
- actual = auth ._get_new_credentials (url , allow_netrc = False , allow_keyring = True )
146
+ actual = auth ._get_new_credentials (url , allow_netrc = False )
145
147
assert actual == expect
146
148
147
149
@@ -185,10 +187,10 @@ def test_keyring_get_password_username_in_index(
185
187
) -> None :
186
188
keyring = KeyringModuleV1 ()
187
189
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
191
192
)
193
+ get = functools .partial (auth ._get_new_credentials , allow_netrc = False )
192
194
193
195
assert get ("http://example.com/path2/path3" ) == ("user" , "user!url" )
194
196
assert get ("http://example.com/path4/path1" ) == (None , None )
@@ -294,12 +296,12 @@ def test_keyring_get_credential(
294
296
monkeypatch : pytest .MonkeyPatch , url : str , expect : str
295
297
) -> None :
296
298
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
301
301
)
302
302
303
+ assert auth ._get_new_credentials (url , allow_netrc = False ) == expect
304
+
303
305
304
306
class KeyringModuleBroken :
305
307
"""Represents the current supported API of keyring, but broken"""
@@ -316,12 +318,10 @@ def test_broken_keyring_disables_keyring(monkeypatch: pytest.MonkeyPatch) -> Non
316
318
keyring_broken = KeyringModuleBroken ()
317
319
monkeypatch .setattr (pip ._internal .network .auth , "keyring" , keyring_broken )
318
320
319
- auth = MultiDomainBasicAuth (index_urls = ["http://example.com/" ])
321
+ auth = MultiDomainBasicAuth (index_urls = ["http://example.com/" ], allow_keyring = True )
320
322
321
323
assert keyring_broken ._call_count == 0
322
324
for i in range (5 ):
323
325
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 )
327
327
assert keyring_broken ._call_count == 1
0 commit comments