diff --git a/Lib/difflib.py b/Lib/difflib.py index 3425e438c98..33e7e6c165a 100644 --- a/Lib/difflib.py +++ b/Lib/difflib.py @@ -1200,6 +1200,25 @@ def context_diff(a, b, fromfile='', tofile='', strings for 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'. The modification times are normally expressed in the ISO 8601 format. If not specified, the strings default to blanks. + + Example: + + >>> print(''.join(context_diff('one\ntwo\nthree\nfour\n'.splitlines(True), + ... 'zero\none\ntree\nfour\n'.splitlines(True), 'Original', 'Current')), + ... end="") + *** Original + --- Current + *************** + *** 1,4 **** + one + ! two + ! three + four + --- 1,4 ---- + + zero + one + ! tree + four """ _check_types(a, b, fromfile, tofile, fromfiledate, tofiledate, lineterm) @@ -1609,7 +1628,7 @@ def _line_pair_iterator(): """ _styles = """ - table.diff {font-family:Courier; border:medium;} + table.diff {font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace; border:medium} .diff_header {background-color:#e0e0e0} td.diff_header {text-align:right} .diff_next {background-color:#c0c0c0} diff --git a/Lib/test/test_difflib.py b/Lib/test/test_difflib.py index 0d669afe61f..6afd90af844 100644 --- a/Lib/test/test_difflib.py +++ b/Lib/test/test_difflib.py @@ -186,6 +186,7 @@ def test_mdiff_catch_stop_iteration(self): the end""" class TestSFpatches(unittest.TestCase): + def test_html_diff(self): # Check SF patch 914575 for generating HTML differences f1a = ((patch914575_from1 + '123\n'*10)*3) diff --git a/Lib/test/test_difflib_expect.html b/Lib/test/test_difflib_expect.html index 3e6a7b7a993..12091206a28 100644 --- a/Lib/test/test_difflib_expect.html +++ b/Lib/test/test_difflib_expect.html @@ -9,7 +9,7 @@ content="text/html; charset=utf-8" />