|
12 | 12 | import ddt |
13 | 13 | import pytest |
14 | 14 |
|
15 | | -from git import NULL_TREE, Diff, DiffIndex, GitCommandError, Repo, Submodule |
| 15 | +from git import NULL_TREE, Diff, DiffIndex, Diffable, GitCommandError, Repo, Submodule |
16 | 16 | from git.cmd import Git |
17 | 17 | from test.lib import StringProcessAdapter, TestBase, fixture, with_rw_directory |
18 | 18 |
|
@@ -352,15 +352,15 @@ def test_diff_submodule(self): |
352 | 352 | self.assertIsInstance(diff.b_blob.size, int) |
353 | 353 |
|
354 | 354 | def test_diff_interface(self): |
355 | | - # Test a few variations of the main diff routine. |
| 355 | + """Test a few variations of the main diff routine.""" |
356 | 356 | assertion_map = {} |
357 | 357 | for i, commit in enumerate(self.rorepo.iter_commits("0.1.6", max_count=2)): |
358 | 358 | diff_item = commit |
359 | 359 | if i % 2 == 0: |
360 | 360 | diff_item = commit.tree |
361 | 361 | # END use tree every second item |
362 | 362 |
|
363 | | - for other in (None, NULL_TREE, commit.Index, commit.parents[0]): |
| 363 | + for other in (None, NULL_TREE, commit.INDEX, commit.parents[0]): |
364 | 364 | for paths in (None, "CHANGES", ("CHANGES", "lib")): |
365 | 365 | for create_patch in range(2): |
366 | 366 | diff_index = diff_item.diff(other=other, paths=paths, create_patch=create_patch) |
@@ -406,10 +406,22 @@ def test_diff_interface(self): |
406 | 406 | diff_index = c.diff(cp, ["does/not/exist"]) |
407 | 407 | self.assertEqual(len(diff_index), 0) |
408 | 408 |
|
| 409 | + def test_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 | + |
409 | 422 | @with_rw_directory |
410 | 423 | def test_rename_override(self, rw_dir): |
411 | | - """Test disabling of diff rename detection""" |
412 | | - |
| 424 | + """Test disabling of diff rename detection.""" |
413 | 425 | # Create and commit file_a.txt. |
414 | 426 | repo = Repo.init(rw_dir) |
415 | 427 | file_a = osp.join(rw_dir, "file_a.txt") |
|
0 commit comments