3030import pytest
3131
3232import pygit2
33- from pygit2 import Repository
33+ from pygit2 import Commit , Repository
3434from pygit2 .enums import BranchType
3535
3636LAST_COMMIT = '2be5719152d4f82c7302b1c0932d8e5f0a4a0e98'
@@ -154,7 +154,7 @@ def test_branches_with_commit(testrepo: Repository) -> None:
154154#
155155
156156
157- def test_lookup_branch_local (testrepo ) :
157+ def test_lookup_branch_local (testrepo : Repository ) -> None :
158158 assert testrepo .lookup_branch ('master' ).target == LAST_COMMIT
159159 assert testrepo .lookup_branch (b'master' ).target == LAST_COMMIT
160160
@@ -167,16 +167,17 @@ def test_lookup_branch_local(testrepo):
167167 assert testrepo .lookup_branch (b'\xb1 ' ) is None
168168
169169
170- def test_listall_branches (testrepo ) :
170+ def test_listall_branches (testrepo : Repository ) -> None :
171171 branches = sorted (testrepo .listall_branches ())
172172 assert branches == ['i18n' , 'master' ]
173173
174- branches = sorted (testrepo .raw_listall_branches ())
175- assert branches == [b'i18n' , b'master' ]
174+ branches_raw = sorted (testrepo .raw_listall_branches ())
175+ assert branches_raw == [b'i18n' , b'master' ]
176176
177177
178- def test_create_branch (testrepo ) :
178+ def test_create_branch (testrepo : Repository ) -> None :
179179 commit = testrepo [LAST_COMMIT ]
180+ assert isinstance (commit , Commit )
180181 testrepo .create_branch ('version1' , commit )
181182 refs = testrepo .listall_branches ()
182183 assert 'version1' in refs
@@ -191,64 +192,72 @@ def test_create_branch(testrepo):
191192 assert testrepo .create_branch ('version1' , commit , True ).target == LAST_COMMIT
192193
193194
194- def test_delete (testrepo ) :
195+ def test_delete (testrepo : Repository ) -> None :
195196 branch = testrepo .lookup_branch ('i18n' )
196197 branch .delete ()
197198
198199 assert testrepo .lookup_branch ('i18n' ) is None
199200
200201
201- def test_cant_delete_master (testrepo ) :
202+ def test_cant_delete_master (testrepo : Repository ) -> None :
202203 branch = testrepo .lookup_branch ('master' )
203204
204205 with pytest .raises (pygit2 .GitError ):
205206 branch .delete ()
206207
207208
208- def test_branch_is_head_returns_true_if_branch_is_head (testrepo ) :
209+ def test_branch_is_head_returns_true_if_branch_is_head (testrepo : Repository ) -> None :
209210 branch = testrepo .lookup_branch ('master' )
210211 assert branch .is_head ()
211212
212213
213- def test_branch_is_head_returns_false_if_branch_is_not_head (testrepo ):
214+ def test_branch_is_head_returns_false_if_branch_is_not_head (
215+ testrepo : Repository ,
216+ ) -> None :
214217 branch = testrepo .lookup_branch ('i18n' )
215218 assert not branch .is_head ()
216219
217220
218- def test_branch_is_checked_out_returns_true_if_branch_is_checked_out (testrepo ):
221+ def test_branch_is_checked_out_returns_true_if_branch_is_checked_out (
222+ testrepo : Repository ,
223+ ) -> None :
219224 branch = testrepo .lookup_branch ('master' )
220225 assert branch .is_checked_out ()
221226
222227
223- def test_branch_is_checked_out_returns_false_if_branch_is_not_checked_out (testrepo ):
228+ def test_branch_is_checked_out_returns_false_if_branch_is_not_checked_out (
229+ testrepo : Repository ,
230+ ) -> None :
224231 branch = testrepo .lookup_branch ('i18n' )
225232 assert not branch .is_checked_out ()
226233
227234
228- def test_branch_rename_succeeds (testrepo ) :
235+ def test_branch_rename_succeeds (testrepo : Repository ) -> None :
229236 branch = testrepo .lookup_branch ('i18n' )
230237 assert branch .rename ('new-branch' ).target == I18N_LAST_COMMIT
231238 assert testrepo .lookup_branch ('new-branch' ).target == I18N_LAST_COMMIT
232239
233240
234- def test_branch_rename_fails_if_destination_already_exists (testrepo ):
241+ def test_branch_rename_fails_if_destination_already_exists (
242+ testrepo : Repository ,
243+ ) -> None :
235244 original_branch = testrepo .lookup_branch ('i18n' )
236245 with pytest .raises (ValueError ):
237246 original_branch .rename ('master' )
238247
239248
240- def test_branch_rename_not_fails_if_force_is_true (testrepo ) :
249+ def test_branch_rename_not_fails_if_force_is_true (testrepo : Repository ) -> None :
241250 branch = testrepo .lookup_branch ('master' )
242251 assert branch .rename ('i18n' , True ).target == LAST_COMMIT
243252
244253
245- def test_branch_rename_fails_with_invalid_names (testrepo ) :
254+ def test_branch_rename_fails_with_invalid_names (testrepo : Repository ) -> None :
246255 original_branch = testrepo .lookup_branch ('i18n' )
247256 with pytest .raises (ValueError ):
248257 original_branch .rename ('abc@{123' )
249258
250259
251- def test_branch_name (testrepo ) :
260+ def test_branch_name (testrepo : Repository ) -> None :
252261 branch = testrepo .lookup_branch ('master' )
253262 assert branch .branch_name == 'master'
254263 assert branch .name == 'refs/heads/master'
0 commit comments