Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2decbe4

Browse files
committed
Test that redefined Diffable.Index should be compatible
This tests the most important characteristics of Diffable.Indexthat must be (and are) preserved in making it an alias of theenumeration constant INDEX instead of a nested class definition.Adding this additional test also allows commit.INDEX to be used inplace of commit.Index in the existing test (since part of what thistests is that they are the same object). That change is also made,along with some very minor cleanup of immediately nearby test code.
1 parentad00c77 commit2decbe4

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

‎test/test_diff.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
importddt
1313
importpytest
1414

15-
fromgitimportNULL_TREE,Diff,DiffIndex,GitCommandError,Repo,Submodule
15+
fromgitimportNULL_TREE,Diff,DiffIndex,Diffable,GitCommandError,Repo,Submodule
1616
fromgit.cmdimportGit
1717
fromtest.libimportStringProcessAdapter,TestBase,fixture,with_rw_directory
1818

@@ -352,15 +352,15 @@ def test_diff_submodule(self):
352352
self.assertIsInstance(diff.b_blob.size,int)
353353

354354
deftest_diff_interface(self):
355-
#Test a few variations of the main diff routine.
355+
"""Test a few variations of the main diff routine."""
356356
assertion_map= {}
357357
fori,commitinenumerate(self.rorepo.iter_commits("0.1.6",max_count=2)):
358358
diff_item=commit
359359
ifi%2==0:
360360
diff_item=commit.tree
361361
# END use tree every second item
362362

363-
forotherin (None,NULL_TREE,commit.Index,commit.parents[0]):
363+
forotherin (None,NULL_TREE,commit.INDEX,commit.parents[0]):
364364
forpathsin (None,"CHANGES", ("CHANGES","lib")):
365365
forcreate_patchinrange(2):
366366
diff_index=diff_item.diff(other=other,paths=paths,create_patch=create_patch)
@@ -406,10 +406,22 @@ def test_diff_interface(self):
406406
diff_index=c.diff(cp, ["does/not/exist"])
407407
self.assertEqual(len(diff_index),0)
408408

409+
deftest_diff_interface_stability(self):
410+
"""Test that the Diffable.Index redefinition should not break compatibility."""
411+
self.assertIs(
412+
Diffable.Index,
413+
Diffable.INDEX,
414+
"The old and new class attribute names must be aliases.",
415+
)
416+
self.assertIs(
417+
type(Diffable.INDEX).__eq__,
418+
object.__eq__,
419+
"Equality comparison must be reference-based.",
420+
)
421+
409422
@with_rw_directory
410423
deftest_rename_override(self,rw_dir):
411-
"""Test disabling of diff rename detection"""
412-
424+
"""Test disabling of diff rename detection."""
413425
# Create and commit file_a.txt.
414426
repo=Repo.init(rw_dir)
415427
file_a=osp.join(rw_dir,"file_a.txt")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp