2626import pytest
2727
2828import pygit2
29+ from pygit2 import Blob , Repository
2930
3031BLOB_OLD_SHA = 'a520c24d85fbfc815d385957eed41406ca5a860b'
3132BLOB_NEW_SHA = '3b18e512dba79e4c8300dd08aeb37f8e728b8dad'
@@ -91,9 +92,11 @@ def test_patch_create_from_buffers():
9192 assert patch .text == BLOB_PATCH
9293
9394
94- def test_patch_create_from_blobs (testrepo ) :
95+ def test_patch_create_from_blobs (testrepo : Repository ) -> None :
9596 old_blob = testrepo [BLOB_OLD_SHA ]
9697 new_blob = testrepo [BLOB_NEW_SHA ]
98+ assert isinstance (old_blob , Blob )
99+ assert isinstance (new_blob , Blob )
97100
98101 patch = pygit2 .Patch .create_from (
99102 old_blob ,
@@ -105,8 +108,9 @@ def test_patch_create_from_blobs(testrepo):
105108 assert patch .text == BLOB_PATCH2
106109
107110
108- def test_patch_create_from_blob_buffer (testrepo ) :
111+ def test_patch_create_from_blob_buffer (testrepo : Repository ) -> None :
109112 old_blob = testrepo [BLOB_OLD_SHA ]
113+ assert isinstance (old_blob , Blob )
110114 patch = pygit2 .Patch .create_from (
111115 old_blob ,
112116 BLOB_NEW_CONTENT ,
@@ -117,7 +121,7 @@ def test_patch_create_from_blob_buffer(testrepo):
117121 assert patch .text == BLOB_PATCH
118122
119123
120- def test_patch_create_from_blob_buffer_add (testrepo ) :
124+ def test_patch_create_from_blob_buffer_add (testrepo : Repository ) -> None :
121125 patch = pygit2 .Patch .create_from (
122126 None ,
123127 BLOB_NEW_CONTENT ,
@@ -128,8 +132,9 @@ def test_patch_create_from_blob_buffer_add(testrepo):
128132 assert patch .text == BLOB_PATCH_ADDED
129133
130134
131- def test_patch_create_from_blob_buffer_delete (testrepo ) :
135+ def test_patch_create_from_blob_buffer_delete (testrepo : Repository ) -> None :
132136 old_blob = testrepo [BLOB_OLD_SHA ]
137+ assert isinstance (old_blob , Blob )
133138
134139 patch = pygit2 .Patch .create_from (
135140 old_blob ,
@@ -141,19 +146,21 @@ def test_patch_create_from_blob_buffer_delete(testrepo):
141146 assert patch .text == BLOB_PATCH_DELETED
142147
143148
144- def test_patch_create_from_bad_old_type_arg (testrepo ) :
149+ def test_patch_create_from_bad_old_type_arg (testrepo : Repository ) -> None :
145150 with pytest .raises (TypeError ):
146- pygit2 .Patch .create_from (testrepo , BLOB_NEW_CONTENT )
151+ pygit2 .Patch .create_from (testrepo , BLOB_NEW_CONTENT ) # type: ignore
147152
148153
149- def test_patch_create_from_bad_new_type_arg (testrepo ) :
154+ def test_patch_create_from_bad_new_type_arg (testrepo : Repository ) -> None :
150155 with pytest .raises (TypeError ):
151- pygit2 .Patch .create_from (None , testrepo )
156+ pygit2 .Patch .create_from (None , testrepo ) # type: ignore
152157
153158
154- def test_context_lines (testrepo ) :
159+ def test_context_lines (testrepo : Repository ) -> None :
155160 old_blob = testrepo [BLOB_OLD_SHA ]
156161 new_blob = testrepo [BLOB_NEW_SHA ]
162+ assert isinstance (old_blob , Blob )
163+ assert isinstance (new_blob , Blob )
157164
158165 patch = pygit2 .Patch .create_from (
159166 old_blob ,
@@ -162,16 +169,19 @@ def test_context_lines(testrepo):
162169 new_as_path = BLOB_NEW_PATH ,
163170 )
164171
172+ assert patch .text is not None
165173 context_count = len (
166174 [line for line in patch .text .splitlines () if line .startswith (' ' )]
167175 )
168176
169177 assert context_count != 0
170178
171179
172- def test_no_context_lines (testrepo ) :
180+ def test_no_context_lines (testrepo : Repository ) -> None :
173181 old_blob = testrepo [BLOB_OLD_SHA ]
174182 new_blob = testrepo [BLOB_NEW_SHA ]
183+ assert isinstance (old_blob , Blob )
184+ assert isinstance (new_blob , Blob )
175185
176186 patch = pygit2 .Patch .create_from (
177187 old_blob ,
@@ -181,16 +191,19 @@ def test_no_context_lines(testrepo):
181191 context_lines = 0 ,
182192 )
183193
194+ assert patch .text is not None
184195 context_count = len (
185196 [line for line in patch .text .splitlines () if line .startswith (' ' )]
186197 )
187198
188199 assert context_count == 0
189200
190201
191- def test_patch_create_blob_blobs (testrepo ) :
202+ def test_patch_create_blob_blobs (testrepo : Repository ) -> None :
192203 old_blob = testrepo [testrepo .create_blob (BLOB_OLD_CONTENT )]
193204 new_blob = testrepo [testrepo .create_blob (BLOB_NEW_CONTENT )]
205+ assert isinstance (old_blob , Blob )
206+ assert isinstance (new_blob , Blob )
194207
195208 patch = pygit2 .Patch .create_from (
196209 old_blob ,
@@ -202,8 +215,9 @@ def test_patch_create_blob_blobs(testrepo):
202215 assert patch .text == BLOB_PATCH
203216
204217
205- def test_patch_create_blob_buffer (testrepo ) :
218+ def test_patch_create_blob_buffer (testrepo : Repository ) -> None :
206219 blob = testrepo [testrepo .create_blob (BLOB_OLD_CONTENT )]
220+ assert isinstance (blob , Blob )
207221 patch = pygit2 .Patch .create_from (
208222 blob ,
209223 BLOB_NEW_CONTENT ,
@@ -214,8 +228,9 @@ def test_patch_create_blob_buffer(testrepo):
214228 assert patch .text == BLOB_PATCH
215229
216230
217- def test_patch_create_blob_delete (testrepo ) :
231+ def test_patch_create_blob_delete (testrepo : Repository ) -> None :
218232 blob = testrepo [testrepo .create_blob (BLOB_OLD_CONTENT )]
233+ assert isinstance (blob , Blob )
219234 patch = pygit2 .Patch .create_from (
220235 blob ,
221236 None ,
@@ -226,8 +241,9 @@ def test_patch_create_blob_delete(testrepo):
226241 assert patch .text == BLOB_PATCH_DELETED
227242
228243
229- def test_patch_create_blob_add (testrepo ) :
244+ def test_patch_create_blob_add (testrepo : Repository ) -> None :
230245 blob = testrepo [testrepo .create_blob (BLOB_NEW_CONTENT )]
246+ assert isinstance (blob , Blob )
231247 patch = pygit2 .Patch .create_from (
232248 None ,
233249 blob ,
@@ -238,8 +254,9 @@ def test_patch_create_blob_add(testrepo):
238254 assert patch .text == BLOB_PATCH_ADDED
239255
240256
241- def test_patch_delete_blob (testrepo ) :
257+ def test_patch_delete_blob (testrepo : Repository ) -> None :
242258 blob = testrepo [BLOB_OLD_SHA ]
259+ assert isinstance (blob , Blob )
243260 patch = pygit2 .Patch .create_from (
244261 blob ,
245262 None ,
@@ -253,12 +270,14 @@ def test_patch_delete_blob(testrepo):
253270 assert patch .text == BLOB_PATCH_DELETED
254271
255272
256- def test_patch_multi_blob (testrepo ) :
273+ def test_patch_multi_blob (testrepo : Repository ) -> None :
257274 blob = testrepo [BLOB_OLD_SHA ]
275+ assert isinstance (blob , Blob )
258276 patch = pygit2 .Patch .create_from (blob , None )
259277 patch_text = patch .text
260278
261279 blob = testrepo [BLOB_OLD_SHA ]
280+ assert isinstance (blob , Blob )
262281 patch2 = pygit2 .Patch .create_from (blob , None )
263282 patch_text2 = patch .text
264283
0 commit comments