MCPcopy Index your code
hub / github.com/python/cpython / test_range_format_context

Method test_range_format_context

Lib/test/test_difflib.py:353–375  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

351 self.assertEqual(fmt(0,0), '0,0')
352
353 def test_range_format_context(self):
354 # Per the diff spec at http://www.unix.org/single_unix_specification/
355 spec = '''\
356 The range of lines in file1 shall be written in the following format
357 if the range contains two or more lines:
358 "*** %d,%d ****\n", <beginning line number>, <ending line number>
359 and the following format otherwise:
360 "*** %d ****\n", <ending line number>
361 The ending line number of an empty range shall be the number of the preceding line,
362 or 0 if the range is at the start of the file.
363
364 Next, the range of lines in file2 shall be written in the following format
365 if the range contains two or more lines:
366 "--- %d,%d ----\n", <beginning line number>, <ending line number>
367 and the following format otherwise:
368 "--- %d ----\n", <ending line number>
369 ''&#x27;
370 fmt = difflib._format_range_context
371 self.assertEqual(fmt(3,3), '3')
372 self.assertEqual(fmt(3,4), '4')
373 self.assertEqual(fmt(3,5), '4,5')
374 self.assertEqual(fmt(3,6), '4,6')
375 self.assertEqual(fmt(0,0), '0')
376
377 @force_colorized
378 def test_unified_diff_colored_output(self):

Callers

nothing calls this directly

Calls 2

fmtFunction · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected