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

Commitcdf7ffc

Browse files
Peter KempterByron
Peter Kempter
authored andcommitted
Add failing unit test
1 parent01f0988 commitcdf7ffc

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

‎test/test_commit.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#
55
# This module is part of GitPython and is released under
66
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
7+
importcopy
78
fromdatetimeimportdatetime
89
fromioimportBytesIO
910
importre
@@ -429,3 +430,48 @@ def test_datetimes(self):
429430
datetime(2009,10,8,20,22,51,tzinfo=tzoffset(-7200)))
430431
self.assertEqual(commit.committed_datetime,
431432
datetime(2009,10,8,18,22,51,tzinfo=utc),commit.committed_datetime)
433+
434+
deftest_trailers(self):
435+
KEY_1="Hello"
436+
VALUE_1="World"
437+
KEY_2="Key"
438+
VALUE_2="Value"
439+
440+
# Check if KEY 1 & 2 with Value 1 & 2 is extracted from multiple msg variations
441+
msgs= []
442+
msgs.append(f"Subject\n\n{KEY_1}:{VALUE_1}\n{KEY_2}:{VALUE_2}\n")
443+
msgs.append(f"Subject\n\nSome body of a function\n\n{KEY_1}:{VALUE_1}\n{KEY_2}:{VALUE_2}\n")
444+
msgs.append(f"Subject\n\nSome body of a function\n\nnon-key: non-value\n\n{KEY_1}:{VALUE_1}\n{KEY_2}:{VALUE_2}\n")
445+
msgs.append(f"Subject\n\nSome multiline\n body of a function\n\nnon-key: non-value\n\n{KEY_1}:{VALUE_1}\n{KEY_2}:{VALUE_2}\n")
446+
447+
formsginmsgs:
448+
commit=self.rorepo.commit('master')
449+
commit=copy.copy(commit)
450+
commit.message=msg
451+
assertKEY_1incommit.trailers.keys()
452+
assertKEY_2incommit.trailers.keys()
453+
assertcommit.trailers[KEY_1]==VALUE_1
454+
assertcommit.trailers[KEY_2]==VALUE_2
455+
456+
# Check that trailer stays empty for multiple msg combinations
457+
msgs= []
458+
msgs.append(f"Subject\n")
459+
msgs.append(f"Subject\n\nBody with some\nText\n")
460+
msgs.append(f"Subject\n\nBody with\nText\n\nContinuation but\n doesn't contain colon\n")
461+
msgs.append(f"Subject\n\nBody with\nText\n\nContinuation but\n only contains one :\n")
462+
msgs.append(f"Subject\n\nBody with\nText\n\nKey: Value\nLine without colon\n")
463+
msgs.append(f"Subject\n\nBody with\nText\n\nLine without colon\nKey: Value\n")
464+
465+
formsginmsgs:
466+
commit=self.rorepo.commit('master')
467+
commit=copy.copy(commit)
468+
commit.message=msg
469+
assertlen(commit.trailers.keys())==0
470+
471+
# check that only the last key value paragraph is evaluated
472+
commit=self.rorepo.commit('master')
473+
commit=copy.copy(commit)
474+
commit.message=f"Subject\n\nMultiline\nBody\n\n{KEY_1}:{VALUE_1}\n\n{KEY_2}:{VALUE_2}\n"
475+
assertKEY_1notincommit.trailers.keys()
476+
assertKEY_2incommit.trailers.keys()
477+
assertcommit.trailers[KEY_2]==VALUE_2

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp