29
29
import pytest
30
30
import os
31
31
from pygit2 .enums import BranchType
32
+ from pygit2 import Repository
32
33
33
34
34
35
LAST_COMMIT = '2be5719152d4f82c7302b1c0932d8e5f0a4a0e98'
38
39
SHARED_COMMIT = '4ec4389a8068641da2d6578db0419484972284c8'
39
40
40
41
41
- def test_branches_getitem (testrepo ) :
42
+ def test_branches_getitem (testrepo : Repository ) -> None :
42
43
branch = testrepo .branches ['master' ]
43
44
assert branch .target == LAST_COMMIT
44
45
@@ -49,12 +50,12 @@ def test_branches_getitem(testrepo):
49
50
testrepo .branches ['not-exists' ]
50
51
51
52
52
- def test_branches (testrepo ) :
53
+ def test_branches (testrepo : Repository ) -> None :
53
54
branches = sorted (testrepo .branches )
54
55
assert branches == ['i18n' , 'master' ]
55
56
56
57
57
- def test_branches_create (testrepo ) :
58
+ def test_branches_create (testrepo : Repository ) -> None :
58
59
commit = testrepo [LAST_COMMIT ]
59
60
reference = testrepo .branches .create ('version1' , commit )
60
61
assert 'version1' in testrepo .branches
@@ -70,53 +71,53 @@ def test_branches_create(testrepo):
70
71
assert reference .target == LAST_COMMIT
71
72
72
73
73
- def test_branches_delete (testrepo ) :
74
+ def test_branches_delete (testrepo : Repository ) -> None :
74
75
testrepo .branches .delete ('i18n' )
75
76
assert testrepo .branches .get ('i18n' ) is None
76
77
77
78
78
- def test_branches_delete_error (testrepo ) :
79
+ def test_branches_delete_error (testrepo : Repository ) -> None :
79
80
with pytest .raises (pygit2 .GitError ):
80
81
testrepo .branches .delete ('master' )
81
82
82
83
83
- def test_branches_is_head (testrepo ) :
84
+ def test_branches_is_head (testrepo : Repository ) -> None :
84
85
branch = testrepo .branches .get ('master' )
85
86
assert branch .is_head ()
86
87
87
88
88
- def test_branches_is_not_head (testrepo ) :
89
+ def test_branches_is_not_head (testrepo : Repository ) -> None :
89
90
branch = testrepo .branches .get ('i18n' )
90
91
assert not branch .is_head ()
91
92
92
93
93
- def test_branches_rename (testrepo ) :
94
+ def test_branches_rename (testrepo : Repository ) -> None :
94
95
new_branch = testrepo .branches ['i18n' ].rename ('new-branch' )
95
96
assert new_branch .target == I18N_LAST_COMMIT
96
97
97
98
new_branch_2 = testrepo .branches .get ('new-branch' )
98
99
assert new_branch_2 .target == I18N_LAST_COMMIT
99
100
100
101
101
- def test_branches_rename_error (testrepo ) :
102
+ def test_branches_rename_error (testrepo : Repository ) -> None :
102
103
original_branch = testrepo .branches .get ('i18n' )
103
104
with pytest .raises (ValueError ):
104
105
original_branch .rename ('master' )
105
106
106
107
107
- def test_branches_rename_force (testrepo ) :
108
+ def test_branches_rename_force (testrepo : Repository ) -> None :
108
109
original_branch = testrepo .branches .get ('master' )
109
110
new_branch = original_branch .rename ('i18n' , True )
110
111
assert new_branch .target == LAST_COMMIT
111
112
112
113
113
- def test_branches_rename_invalid (testrepo ) :
114
+ def test_branches_rename_invalid (testrepo : Repository ) -> None :
114
115
original_branch = testrepo .branches .get ('i18n' )
115
116
with pytest .raises (ValueError ):
116
117
original_branch .rename ('abc@{123' )
117
118
118
119
119
- def test_branches_name (testrepo ) :
120
+ def test_branches_name (testrepo : Repository ) -> None :
120
121
branch = testrepo .branches .get ('master' )
121
122
assert branch .branch_name == 'master'
122
123
assert branch .name == 'refs/heads/master'
@@ -128,7 +129,7 @@ def test_branches_name(testrepo):
128
129
assert branch .raw_branch_name == branch .branch_name .encode ('utf-8' )
129
130
130
131
131
- def test_branches_with_commit (testrepo ) :
132
+ def test_branches_with_commit (testrepo : Repository ) -> None :
132
133
branches = testrepo .branches .with_commit (EXCLUSIVE_MASTER_COMMIT )
133
134
assert sorted (branches ) == ['master' ]
134
135
assert branches .get ('i18n' ) is None
0 commit comments