2929import pytest
3030
3131import pygit2
32- from pygit2 import Keypair , KeypairFromAgent , KeypairFromMemory , Username , UserPass
32+ from pygit2 import (
33+ Keypair ,
34+ KeypairFromAgent ,
35+ KeypairFromMemory ,
36+ Repository ,
37+ Username ,
38+ UserPass ,
39+ )
3340from pygit2 .enums import CredentialType
3441
3542from . import utils
4451ORIGIN_REFSPEC = '+refs/heads/*:refs/remotes/origin/*'
4552
4653
47- def test_username ():
54+ def test_username () -> None :
4855 username = 'git'
4956 cred = Username (username )
5057 assert (username ,) == cred .credential_tuple
5158
5259
53- def test_userpass ():
60+ def test_userpass () -> None :
5461 username = 'git'
5562 password = 'sekkrit'
5663
5764 cred = UserPass (username , password )
5865 assert (username , password ) == cred .credential_tuple
5966
6067
61- def test_ssh_key ():
68+ def test_ssh_key () -> None :
6269 username = 'git'
6370 pubkey = 'id_rsa.pub'
6471 privkey = 'id_rsa'
@@ -68,7 +75,7 @@ def test_ssh_key():
6875 assert (username , pubkey , privkey , passphrase ) == cred .credential_tuple
6976
7077
71- def test_ssh_key_aspath ():
78+ def test_ssh_key_aspath () -> None :
7279 username = 'git'
7380 pubkey = Path ('id_rsa.pub' )
7481 privkey = Path ('id_rsa' )
@@ -78,14 +85,14 @@ def test_ssh_key_aspath():
7885 assert (username , pubkey , privkey , passphrase ) == cred .credential_tuple
7986
8087
81- def test_ssh_agent ():
88+ def test_ssh_agent () -> None :
8289 username = 'git'
8390
8491 cred = KeypairFromAgent (username )
8592 assert (username , None , None , None ) == cred .credential_tuple
8693
8794
88- def test_ssh_from_memory ():
95+ def test_ssh_from_memory () -> None :
8996 username = 'git'
9097 pubkey = 'public key data'
9198 privkey = 'private key data'
@@ -97,7 +104,7 @@ def test_ssh_from_memory():
97104
98105@utils .requires_network
99106@utils .requires_ssh
100- def test_keypair (tmp_path , pygit2_empty_key ) :
107+ def test_keypair (tmp_path : Path , pygit2_empty_key : tuple [ Path , str , str ]) -> None :
101108 url = 'ssh://[email protected] /pygit2/empty' 102109 with pytest .raises (pygit2 .GitError ):
103110 pygit2 .clone_repository (url , tmp_path )
@@ -111,7 +118,9 @@ def test_keypair(tmp_path, pygit2_empty_key):
111118
112119@utils .requires_network
113120@utils .requires_ssh
114- def test_keypair_from_memory (tmp_path , pygit2_empty_key ):
121+ def test_keypair_from_memory (
122+ tmp_path : Path , pygit2_empty_key : tuple [Path , str , str ]
123+ ) -> None :
115124 url = 'ssh://[email protected] /pygit2/empty' 116125 with pytest .raises (pygit2 .GitError ):
117126 pygit2 .clone_repository (url , tmp_path )
@@ -128,7 +137,7 @@ def test_keypair_from_memory(tmp_path, pygit2_empty_key):
128137 pygit2 .clone_repository (url , tmp_path , callbacks = callbacks )
129138
130139
131- def test_callback (testrepo ):
140+ def test_callback (testrepo : Repository ):
132141 class MyCallbacks (pygit2 .RemoteCallbacks ):
133142 def credentials (testrepo , url , username , allowed ):
134143 assert allowed & CredentialType .USERPASS_PLAINTEXT
@@ -141,7 +150,7 @@ def credentials(testrepo, url, username, allowed):
141150
142151
143152@utils .requires_network
144- def test_bad_cred_type (testrepo ):
153+ def test_bad_cred_type (testrepo : Repository ):
145154 class MyCallbacks (pygit2 .RemoteCallbacks ):
146155 def credentials (testrepo , url , username , allowed ):
147156 assert allowed & CredentialType .USERPASS_PLAINTEXT
@@ -154,7 +163,7 @@ def credentials(testrepo, url, username, allowed):
154163
155164
156165@utils .requires_network
157- def test_fetch_certificate_check (testrepo ):
166+ def test_fetch_certificate_check (testrepo : Repository ):
158167 class MyCallbacks (pygit2 .RemoteCallbacks ):
159168 def certificate_check (testrepo , certificate , valid , host ):
160169 assert certificate is None
@@ -179,7 +188,7 @@ def certificate_check(testrepo, certificate, valid, host):
179188
180189
181190@utils .requires_network
182- def test_user_pass (testrepo ):
191+ def test_user_pass (testrepo : Repository ):
183192 credentials = UserPass ('libgit2' , 'libgit2' )
184193 callbacks = pygit2 .RemoteCallbacks (credentials = credentials )
185194
@@ -191,7 +200,7 @@ def test_user_pass(testrepo):
191200@utils .requires_proxy
192201@utils .requires_network
193202@utils .requires_future_libgit2
194- def test_proxy (testrepo ):
203+ def test_proxy (testrepo : Repository ):
195204 credentials = UserPass ('libgit2' , 'libgit2' )
196205 callbacks = pygit2 .RemoteCallbacks (credentials = credentials )
197206
0 commit comments