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

Commitc0e69a4

Browse files
author
Cesar Velazquez
committed
Updated diff test to use different similarity thresholds
1 parent186d75c commitc0e69a4

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

‎test/test_diff.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,17 +420,17 @@ def test_rename_override(self, rw_dir):
420420
repo=Repo.init(rw_dir)
421421
file_a=osp.join(rw_dir,"file_a.txt")
422422
withopen(file_a,"w",encoding='utf-8')asoutfile:
423-
outfile.write("hello world")
423+
outfile.write("hello world\n")
424424
repo.git.add(Git.polish_url(file_a))
425425
repo.git.commit(message="Added file_a.txt")
426426

427427
# remove file_a.txt
428428
repo.git.rm(Git.polish_url(file_a))
429429

430-
# create and commit file_b.txt
430+
# create and commit file_b.txt with similarity index of 52
431431
file_b=osp.join(rw_dir,"file_b.txt")
432432
withopen(file_b,"w",encoding='utf-8')asoutfile:
433-
outfile.write("hello world")
433+
outfile.write("hello world\nhello world")
434434
repo.git.add(Git.polish_url(file_b))
435435
repo.git.commit(message="Removed file_a.txt. Added file_b.txt")
436436

@@ -458,3 +458,26 @@ def test_rename_override(self, rw_dir):
458458
diff=diffs[1]
459459
self.assertEqual(True,diff.new_file)
460460
self.assertEqual('file_b.txt',diff.a_path)
461+
462+
# check diff with high similarity index
463+
diffs=commit_b.diff(commit_a,split_single_char_options=False,M='75%')
464+
self.assertEqual(2,len(diffs))
465+
466+
# check fileA.txt deleted
467+
diff=diffs[0]
468+
self.assertEqual(True,diff.deleted_file)
469+
self.assertEqual('file_a.txt',diff.a_path)
470+
471+
# check fileB.txt added
472+
diff=diffs[1]
473+
self.assertEqual(True,diff.new_file)
474+
self.assertEqual('file_b.txt',diff.a_path)
475+
476+
# check diff with low similarity index
477+
diffs=commit_b.diff(commit_a,split_single_char_options=False,M='40%')
478+
self.assertEqual(1,len(diffs))
479+
diff=diffs[0]
480+
self.assertEqual(True,diff.renamed_file)
481+
self.assertEqual('file_a.txt',diff.rename_from)
482+
self.assertEqual('file_b.txt',diff.rename_to)
483+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp