Skip to content

Commit d463fd7

Browse files
committed
Make broken patch tests be less nebulous
1 parent 798e357 commit d463fd7

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

test/test_patch.py

+28-23
Original file line numberDiff line numberDiff line change
@@ -201,31 +201,36 @@ def test_patch_create_blob_add(self):
201201

202202
self.assertEqual(patch.patch, BLOB_PATCH_ADDED)
203203

204-
def test_patch_multi_content(self):
205-
patch_text = []
206-
patches = []
207-
for content in [BLOB_OLD_CONTENT, BLOB_NEW_CONTENT]*10:
208-
patch = pygit2.Patch.create_from(
209-
content,
210-
None,
211-
)
212-
213-
patch_text.append(patch.patch)
214-
patches.append(patch)
204+
def test_patch_delete_blob(self):
205+
blob = self.repo[BLOB_OLD_SHA]
206+
patch = pygit2.Patch.create_from(
207+
blob,
208+
None,
209+
old_as_path=BLOB_OLD_PATH,
210+
new_as_path=BLOB_NEW_PATH,
211+
)
215212

216-
self.assertEqual(patch_text, [patch.patch for patch in patches])
213+
# Make sure that even after deleting the blob the patch still has the
214+
# necessary references to generate its patch
215+
del blob
216+
self.assertEqual(patch.patch, BLOB_PATCH_DELETED)
217217

218218
def test_patch_multi_blob(self):
219-
patch_text = []
220-
patches = []
221-
for sha in [BLOB_OLD_SHA, BLOB_NEW_SHA]*10:
222-
blob = self.repo[sha]
223-
patch = pygit2.Patch.create_from(
224-
blob,
225-
None
226-
)
219+
blob = self.repo[BLOB_OLD_SHA]
220+
patch = pygit2.Patch.create_from(
221+
blob,
222+
None
223+
)
224+
patch_text = patch.patch
227225

228-
patch_text.append(patch.patch)
229-
patches.append(patch)
226+
blob = self.repo[BLOB_OLD_SHA]
227+
patch2 = pygit2.Patch.create_from(
228+
blob,
229+
None
230+
)
231+
patch_text2 = patch.patch
230232

231-
self.assertEqual(patch_text, [patch.patch for patch in patches])
233+
self.assertEqual(patch_text, patch_text2)
234+
self.assertEqual(patch_text, patch.patch)
235+
self.assertEqual(patch_text2, patch2.patch)
236+
self.assertEqual(patch.patch, patch2.patch)

0 commit comments

Comments
 (0)