mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
Issue #7585: use tab between components in unified and context diff headers.
Instead of spaces between the filename and date (or whatever the string is that follows the filename, if any) use tabs. This is what the unix 'diff' command does, for example, and difflib was intended to follow the 'standard' way of doing diffs. This improves compatibility with patch tools. The docs and examples are also changed to recommended that the date format used be the ISO 8601 format, which is what modern diff tools emit by default. Patch by Anatoly Techtonik.
This commit is contained in:
parent
9aca91d7d7
commit
1a14d3d169
5 changed files with 51 additions and 21 deletions
|
@ -159,10 +159,32 @@ class TestSFpatches(unittest.TestCase):
|
|||
difflib.SequenceMatcher(None, old, new).get_opcodes()
|
||||
|
||||
|
||||
class TestOutputFormat(unittest.TestCase):
|
||||
def test_tab_delimiter(self):
|
||||
args = ['one', 'two', 'Original', 'Current',
|
||||
'2005-01-26 23:30:50', '2010-04-02 10:20:52']
|
||||
ud = difflib.unified_diff(*args, lineterm='')
|
||||
self.assertEqual(list(ud)[0:2], [
|
||||
"--- Original\t2005-01-26 23:30:50",
|
||||
"+++ Current\t2010-04-02 10:20:52"])
|
||||
cd = difflib.context_diff(*args, lineterm='')
|
||||
self.assertEqual(list(cd)[0:2], [
|
||||
"*** Original\t2005-01-26 23:30:50",
|
||||
"--- Current\t2010-04-02 10:20:52"])
|
||||
|
||||
def test_no_trailing_tab_on_empty_filedate(self):
|
||||
args = ['one', 'two', 'Original', 'Current']
|
||||
ud = difflib.unified_diff(*args, lineterm='')
|
||||
self.assertEqual(list(ud)[0:2], ["--- Original", "+++ Current"])
|
||||
|
||||
cd = difflib.context_diff(*args, lineterm='')
|
||||
self.assertEqual(list(cd)[0:2], ["*** Original", "--- Current"])
|
||||
|
||||
|
||||
def test_main():
|
||||
difflib.HtmlDiff._default_prefix = 0
|
||||
Doctests = doctest.DocTestSuite(difflib)
|
||||
run_unittest(TestSFpatches, TestSFbugs, Doctests)
|
||||
run_unittest(TestSFpatches, TestSFbugs, TestOutputFormat, Doctests)
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue