summaryrefslogtreecommitdiff
path: root/Lib/test/test_difflib.py
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2010-04-12 16:58:02 +0000
committerR. David Murray <rdmurray@bitdance.com>2010-04-12 16:58:02 +0000
commitb2416e54b15d90b4a1bc917897912061830b42fc (patch)
treea5873595439ad16bde67329092d7a0e0af78c0ac /Lib/test/test_difflib.py
parentaf9c3cfd443692cfbb89d5a8eedf175356611b53 (diff)
downloadcpython-git-b2416e54b15d90b4a1bc917897912061830b42fc.tar.gz
Merged revisions 80004 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r80004 | r.david.murray | 2010-04-12 12:35:19 -0400 (Mon, 12 Apr 2010) | 13 lines 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. ........
Diffstat (limited to 'Lib/test/test_difflib.py')
-rw-r--r--Lib/test/test_difflib.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/Lib/test/test_difflib.py b/Lib/test/test_difflib.py
index 852aae9b31..6c9bde61a4 100644
--- a/Lib/test/test_difflib.py
+++ b/Lib/test/test_difflib.py
@@ -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()