29
29
30
30
import pytest
31
31
32
- from pygit2 import Commit , Signature , Tree , reference_is_valid_name
32
+ from pygit2 import Commit , Signature , Tree , reference_is_valid_name , Repository
33
33
from pygit2 import AlreadyExistsError , GitError , InvalidSpecError
34
34
from pygit2 .enums import ReferenceType
35
35
@@ -45,7 +45,7 @@ def test_refs_list_objects(testrepo):
45
45
]
46
46
47
47
48
- def test_refs_list (testrepo ) :
48
+ def test_refs_list (testrepo : Repository ) -> None :
49
49
# Without argument
50
50
assert sorted (testrepo .references ) == ['refs/heads/i18n' , 'refs/heads/master' ]
51
51
@@ -58,13 +58,13 @@ def test_refs_list(testrepo):
58
58
]
59
59
60
60
61
- def test_head (testrepo ) :
61
+ def test_head (testrepo : Repository ) -> None :
62
62
head = testrepo .head
63
63
assert LAST_COMMIT == testrepo [head .target ].id
64
64
assert LAST_COMMIT == testrepo [head .raw_target ].id
65
65
66
66
67
- def test_refs_getitem (testrepo ) :
67
+ def test_refs_getitem (testrepo : Repository ) -> None :
68
68
refname = 'refs/foo'
69
69
# Raise KeyError ?
70
70
with pytest .raises (KeyError ):
@@ -78,37 +78,37 @@ def test_refs_getitem(testrepo):
78
78
assert reference .name == 'refs/heads/master'
79
79
80
80
81
- def test_refs_get_sha (testrepo ) :
81
+ def test_refs_get_sha (testrepo : Repository ) -> None :
82
82
reference = testrepo .references ['refs/heads/master' ]
83
83
assert reference .target == LAST_COMMIT
84
84
85
85
86
- def test_refs_set_sha (testrepo ) :
86
+ def test_refs_set_sha (testrepo : Repository ) -> None :
87
87
NEW_COMMIT = '5ebeeebb320790caf276b9fc8b24546d63316533'
88
88
reference = testrepo .references .get ('refs/heads/master' )
89
89
reference .set_target (NEW_COMMIT )
90
90
assert reference .target == NEW_COMMIT
91
91
92
92
93
- def test_refs_set_sha_prefix (testrepo ) :
93
+ def test_refs_set_sha_prefix (testrepo : Repository ) -> None :
94
94
NEW_COMMIT = '5ebeeebb320790caf276b9fc8b24546d63316533'
95
95
reference = testrepo .references .get ('refs/heads/master' )
96
96
reference .set_target (NEW_COMMIT [0 :6 ])
97
97
assert reference .target == NEW_COMMIT
98
98
99
99
100
- def test_refs_get_type (testrepo ) :
100
+ def test_refs_get_type (testrepo : Repository ) -> None :
101
101
reference = testrepo .references .get ('refs/heads/master' )
102
102
assert reference .type == ReferenceType .DIRECT
103
103
104
104
105
- def test_refs_get_target (testrepo ) :
105
+ def test_refs_get_target (testrepo : Repository ) -> None :
106
106
reference = testrepo .references .get ('HEAD' )
107
107
assert reference .target == 'refs/heads/master'
108
108
assert reference .raw_target == b'refs/heads/master'
109
109
110
110
111
- def test_refs_set_target (testrepo ) :
111
+ def test_refs_set_target (testrepo : Repository ) -> None :
112
112
reference = testrepo .references .get ('HEAD' )
113
113
assert reference .target == 'refs/heads/master'
114
114
assert reference .raw_target == b'refs/heads/master'
@@ -117,14 +117,14 @@ def test_refs_set_target(testrepo):
117
117
assert reference .raw_target == b'refs/heads/i18n'
118
118
119
119
120
- def test_refs_get_shorthand (testrepo ) :
120
+ def test_refs_get_shorthand (testrepo : Repository ) -> None :
121
121
reference = testrepo .references .get ('refs/heads/master' )
122
122
assert reference .shorthand == 'master'
123
123
reference = testrepo .references .create ('refs/remotes/origin/master' , LAST_COMMIT )
124
124
assert reference .shorthand == 'origin/master'
125
125
126
126
127
- def test_refs_set_target_with_message (testrepo ) :
127
+ def test_refs_set_target_with_message (testrepo : Repository ) -> None :
128
128
reference = testrepo .references .get ('HEAD' )
129
129
assert reference .target == 'refs/heads/master'
130
130
assert reference .raw_target == b'refs/heads/master'
@@ -139,7 +139,7 @@ def test_refs_set_target_with_message(testrepo):
139
139
assert first .committer == sig
140
140
141
141
142
- def test_refs_delete (testrepo ) :
142
+ def test_refs_delete (testrepo : Repository ) -> None :
143
143
# We add a tag as a new reference that points to "origin/master"
144
144
reference = testrepo .references .create ('refs/tags/version1' , LAST_COMMIT )
145
145
assert 'refs/tags/version1' in testrepo .references
@@ -163,7 +163,7 @@ def test_refs_delete(testrepo):
163
163
reference .rename ('refs/tags/version2' )
164
164
165
165
166
- def test_refs_rename (testrepo ) :
166
+ def test_refs_rename (testrepo : Repository ) -> None :
167
167
# We add a tag as a new reference that points to "origin/master"
168
168
reference = testrepo .references .create ('refs/tags/version1' , LAST_COMMIT )
169
169
assert reference .name == 'refs/tags/version1'
@@ -177,7 +177,7 @@ def test_refs_rename(testrepo):
177
177
reference .rename ('b1' )
178
178
179
179
180
- # def test_reload(testrepo) :
180
+ # def test_reload(testrepo: Repository) -> None :
181
181
# name = 'refs/tags/version1'
182
182
# ref = testrepo.create_reference(name, "refs/heads/master", symbolic=True)
183
183
# ref2 = testrepo.lookup_reference(name)
@@ -187,21 +187,21 @@ def test_refs_rename(testrepo):
187
187
# with pytest.raises(GitError): getattr(ref2, 'name')
188
188
189
189
190
- def test_refs_resolve (testrepo ) :
190
+ def test_refs_resolve (testrepo : Repository ) -> None :
191
191
reference = testrepo .references .get ('HEAD' )
192
192
assert reference .type == ReferenceType .SYMBOLIC
193
193
reference = reference .resolve ()
194
194
assert reference .type == ReferenceType .DIRECT
195
195
assert reference .target == LAST_COMMIT
196
196
197
197
198
- def test_refs_resolve_identity (testrepo ) :
198
+ def test_refs_resolve_identity (testrepo : Repository ) -> None :
199
199
head = testrepo .references .get ('HEAD' )
200
200
ref = head .resolve ()
201
201
assert ref .resolve () is ref
202
202
203
203
204
- def test_refs_create (testrepo ) :
204
+ def test_refs_create (testrepo : Repository ) -> None :
205
205
# We add a tag as a new reference that points to "origin/master"
206
206
reference = testrepo .references .create ('refs/tags/version1' , LAST_COMMIT )
207
207
refs = testrepo .references
@@ -220,7 +220,7 @@ def test_refs_create(testrepo):
220
220
assert reference .target == LAST_COMMIT
221
221
222
222
223
- def test_refs_create_symbolic (testrepo ) :
223
+ def test_refs_create_symbolic (testrepo : Repository ) -> None :
224
224
# We add a tag as a new symbolic reference that always points to
225
225
# "refs/heads/master"
226
226
reference = testrepo .references .create ('refs/tags/beta' , 'refs/heads/master' )
@@ -241,11 +241,11 @@ def test_refs_create_symbolic(testrepo):
241
241
assert reference .raw_target == b'refs/heads/master'
242
242
243
243
244
- # def test_packall_references(testrepo) :
244
+ # def test_packall_references(testrepo: Repository) -> None :
245
245
# testrepo.packall_references()
246
246
247
247
248
- def test_refs_peel (testrepo ) :
248
+ def test_refs_peel (testrepo : Repository ) -> None :
249
249
ref = testrepo .references .get ('refs/heads/master' )
250
250
assert testrepo [ref .target ].id == ref .peel ().id
251
251
assert testrepo [ref .raw_target ].id == ref .peel ().id
@@ -254,7 +254,7 @@ def test_refs_peel(testrepo):
254
254
assert commit .tree .id == ref .peel (Tree ).id
255
255
256
256
257
- def test_refs_equality (testrepo ) :
257
+ def test_refs_equality (testrepo : Repository ) -> None :
258
258
ref1 = testrepo .references .get ('refs/heads/master' )
259
259
ref2 = testrepo .references .get ('refs/heads/master' )
260
260
ref3 = testrepo .references .get ('refs/heads/i18n' )
@@ -267,7 +267,7 @@ def test_refs_equality(testrepo):
267
267
assert not ref1 == ref3
268
268
269
269
270
- def test_refs_compress (testrepo ) :
270
+ def test_refs_compress (testrepo : Repository ) -> None :
271
271
packed_refs_file = Path (testrepo .path ) / 'packed-refs'
272
272
assert not packed_refs_file .exists ()
273
273
old_refs = [(ref .name , ref .target ) for ref in testrepo .references .objects ]
0 commit comments