Skip to content

Commit 5c5b248

Browse files
committed
Add test case
1 parent 6d5a8c2 commit 5c5b248

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Lib/test/test_difflib.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,21 @@ def test_range_format_context(self):
355355
self.assertEqual(fmt(3,6), '4,6')
356356
self.assertEqual(fmt(0,0), '0')
357357

358+
def test_unified_diff_colored_output(self):
359+
args = [['one', 'three'], ['two', 'three'], 'Original', 'Current',
360+
'2005-01-26 23:30:50', '2010-04-02 10:20:52']
361+
actual = list(difflib.unified_diff(*args, lineterm='', color=True))
362+
363+
expect = [
364+
"\033[1m--- Original\t2005-01-26 23:30:50\033[m",
365+
"\033[1m+++ Current\t2010-04-02 10:20:52\033[m",
366+
"\033[36m@@ -1,2 +1,2 @@\033[m",
367+
"\033[31m-one\033[m",
368+
"\033[32m+two\033[m",
369+
" three",
370+
]
371+
self.assertEqual(expect, actual)
372+
358373

359374
class TestBytes(unittest.TestCase):
360375
# don't really care about the content of the output, just the fact

0 commit comments

Comments
 (0)