3333import pytest
3434
3535import pygit2
36+ from pygit2 import Repository
3637from pygit2 .enums import ObjectType
3738
3839from . import utils
8081"""
8182
8283
83- def test_read_blob (testrepo ) :
84+ def test_read_blob (testrepo : Repository ) -> None :
8485 blob = testrepo [BLOB_SHA ]
8586 assert blob .id == BLOB_SHA
8687 assert blob .id == BLOB_SHA
@@ -92,7 +93,7 @@ def test_read_blob(testrepo):
9293 assert BLOB_CONTENT == blob .read_raw ()
9394
9495
95- def test_create_blob (testrepo ) :
96+ def test_create_blob (testrepo : Repository ) -> None :
9697 blob_oid = testrepo .create_blob (BLOB_NEW_CONTENT )
9798 blob = testrepo [blob_oid ]
9899
@@ -116,7 +117,7 @@ def set_content():
116117 set_content ()
117118
118119
119- def test_create_blob_fromworkdir (testrepo ) :
120+ def test_create_blob_fromworkdir (testrepo : Repository ) -> None :
120121 blob_oid = testrepo .create_blob_fromworkdir ('bye.txt' )
121122 blob = testrepo [blob_oid ]
122123
@@ -131,29 +132,29 @@ def test_create_blob_fromworkdir(testrepo):
131132 assert BLOB_FILE_CONTENT == blob .read_raw ()
132133
133134
134- def test_create_blob_fromworkdir_aspath (testrepo ) :
135+ def test_create_blob_fromworkdir_aspath (testrepo : Repository ) -> None :
135136 blob_oid = testrepo .create_blob_fromworkdir (Path ('bye.txt' ))
136137 blob = testrepo [blob_oid ]
137138
138139 assert isinstance (blob , pygit2 .Blob )
139140
140141
141- def test_create_blob_outside_workdir (testrepo ) :
142+ def test_create_blob_outside_workdir (testrepo : Repository ) -> None :
142143 with pytest .raises (KeyError ):
143144 testrepo .create_blob_fromworkdir (__file__ )
144145
145146
146- def test_create_blob_fromdisk (testrepo ) :
147+ def test_create_blob_fromdisk (testrepo : Repository ) -> None :
147148 blob_oid = testrepo .create_blob_fromdisk (__file__ )
148149 blob = testrepo [blob_oid ]
149150
150151 assert isinstance (blob , pygit2 .Blob )
151152 assert ObjectType .BLOB == blob .type
152153
153154
154- def test_create_blob_fromiobase (testrepo ) :
155+ def test_create_blob_fromiobase (testrepo : Repository ) -> None :
155156 with pytest .raises (TypeError ):
156- testrepo .create_blob_fromiobase ('bad type' )
157+ testrepo .create_blob_fromiobase ('bad type' ) # type: ignore
157158
158159 f = io .BytesIO (BLOB_CONTENT )
159160 blob_oid = testrepo .create_blob_fromiobase (f )
@@ -166,54 +167,64 @@ def test_create_blob_fromiobase(testrepo):
166167 assert BLOB_SHA == blob_oid
167168
168169
169- def test_diff_blob (testrepo ) :
170+ def test_diff_blob (testrepo : Repository ) -> None :
170171 blob = testrepo [BLOB_SHA ]
172+ assert isinstance (blob , pygit2 .Blob )
171173 old_blob = testrepo ['3b18e512dba79e4c8300dd08aeb37f8e728b8dad' ]
174+ assert isinstance (old_blob , pygit2 .Blob )
172175 patch = blob .diff (old_blob , old_as_path = 'hello.txt' )
173176 assert len (patch .hunks ) == 1
174177
175178
176- def test_diff_blob_to_buffer (testrepo ) :
179+ def test_diff_blob_to_buffer (testrepo : Repository ) -> None :
177180 blob = testrepo [BLOB_SHA ]
181+ assert isinstance (blob , pygit2 .Blob )
178182 patch = blob .diff_to_buffer ('hello world' )
179183 assert len (patch .hunks ) == 1
180184
181185
182- def test_diff_blob_to_buffer_patch_patch (testrepo ) :
186+ def test_diff_blob_to_buffer_patch_patch (testrepo : Repository ) -> None :
183187 blob = testrepo [BLOB_SHA ]
188+ assert isinstance (blob , pygit2 .Blob )
184189 patch = blob .diff_to_buffer ('hello world' )
185190 assert patch .text == BLOB_PATCH
186191
187192
188- def test_diff_blob_to_buffer_delete (testrepo ) :
193+ def test_diff_blob_to_buffer_delete (testrepo : Repository ) -> None :
189194 blob = testrepo [BLOB_SHA ]
195+ assert isinstance (blob , pygit2 .Blob )
190196 patch = blob .diff_to_buffer (None )
191197 assert patch .text == BLOB_PATCH_DELETED
192198
193199
194- def test_diff_blob_create (testrepo ) :
200+ def test_diff_blob_create (testrepo : Repository ) -> None :
195201 old = testrepo [testrepo .create_blob (BLOB_CONTENT )]
196202 new = testrepo [testrepo .create_blob (BLOB_NEW_CONTENT )]
203+ assert isinstance (old , pygit2 .Blob )
204+ assert isinstance (new , pygit2 .Blob )
197205
198206 patch = old .diff (new )
199207 assert patch .text == BLOB_PATCH_2
200208
201209
202- def test_blob_from_repo (testrepo ) :
210+ def test_blob_from_repo (testrepo : Repository ) -> None :
203211 blob = testrepo [BLOB_SHA ]
212+ assert isinstance (blob , pygit2 .Blob )
204213 patch_one = blob .diff_to_buffer (None )
205214
206215 blob = testrepo [BLOB_SHA ]
216+ assert isinstance (blob , pygit2 .Blob )
207217 patch_two = blob .diff_to_buffer (None )
208218
209219 assert patch_one .text == patch_two .text
210220
211221
212- def test_blob_write_to_queue (testrepo ) :
213- queue = Queue ()
222+ def test_blob_write_to_queue (testrepo : Repository ) -> None :
223+ queue : Queue [ bytes ] = Queue ()
214224 ready = Event ()
215225 done = Event ()
216226 blob = testrepo [BLOB_SHA ]
227+ assert isinstance (blob , pygit2 .Blob )
217228 blob ._write_to_queue (queue , ready , done )
218229 assert ready .wait ()
219230 assert done .wait ()
@@ -223,12 +234,13 @@ def test_blob_write_to_queue(testrepo):
223234 assert BLOB_CONTENT == b'' .join (chunks )
224235
225236
226- def test_blob_write_to_queue_filtered (testrepo ) :
227- queue = Queue ()
237+ def test_blob_write_to_queue_filtered (testrepo : Repository ) -> None :
238+ queue : Queue [ bytes ] = Queue ()
228239 ready = Event ()
229240 done = Event ()
230241 blob_oid = testrepo .create_blob_fromworkdir ('bye.txt' )
231242 blob = testrepo [blob_oid ]
243+ assert isinstance (blob , pygit2 .Blob )
232244 blob ._write_to_queue (queue , ready , done , as_path = 'bye.txt' )
233245 assert ready .wait ()
234246 assert done .wait ()
@@ -238,17 +250,19 @@ def test_blob_write_to_queue_filtered(testrepo):
238250 assert b'bye world\n ' == b'' .join (chunks )
239251
240252
241- def test_blobio (testrepo ) :
253+ def test_blobio (testrepo : Repository ) -> None :
242254 blob_oid = testrepo .create_blob_fromworkdir ('bye.txt' )
243255 blob = testrepo [blob_oid ]
256+ assert isinstance (blob , pygit2 .Blob )
244257 with pygit2 .BlobIO (blob ) as reader :
245258 assert b'bye world\n ' == reader .read ()
246- assert not reader .raw ._thread .is_alive ()
259+ assert not reader .raw ._thread .is_alive () # type: ignore[attr-defined]
247260
248261
249- def test_blobio_filtered (testrepo ) :
262+ def test_blobio_filtered (testrepo : Repository ) -> None :
250263 blob_oid = testrepo .create_blob_fromworkdir ('bye.txt' )
251264 blob = testrepo [blob_oid ]
265+ assert isinstance (blob , pygit2 .Blob )
252266 with pygit2 .BlobIO (blob , as_path = 'bye.txt' ) as reader :
253267 assert b'bye world\n ' == reader .read ()
254- assert not reader .raw ._thread .is_alive ()
268+ assert not reader .raw ._thread .is_alive () # type: ignore[attr-defined]
0 commit comments