Back to index

python3.2  3.2.2
Public Member Functions
test.test_difflib.TestOutputFormat Class Reference

List of all members.

Public Member Functions

def test_tab_delimiter
def test_no_trailing_tab_on_empty_filedate
def test_range_format_unified
def test_range_format_context

Detailed Description

Definition at line 218 of file test_difflib.py.


Member Function Documentation

Definition at line 231 of file test_difflib.py.

00231 
00232     def test_no_trailing_tab_on_empty_filedate(self):
00233         args = ['one', 'two', 'Original', 'Current']
00234         ud = difflib.unified_diff(*args, lineterm='')
00235         self.assertEqual(list(ud)[0:2], ["--- Original", "+++ Current"])
00236 
00237         cd = difflib.context_diff(*args, lineterm='')
00238         self.assertEqual(list(cd)[0:2], ["*** Original", "--- Current"])

Here is the call graph for this function:

Definition at line 256 of file test_difflib.py.

00256 
00257     def test_range_format_context(self):
00258         # Per the diff spec at http://www.unix.org/single_unix_specification/
00259         spec = '''\
00260            The range of lines in file1 shall be written in the following format
00261            if the range contains two or more lines:
00262                "*** %d,%d ****\n", <beginning line number>, <ending line number>
00263            and the following format otherwise:
00264                "*** %d ****\n", <ending line number>
00265            The ending line number of an empty range shall be the number of the preceding line,
00266            or 0 if the range is at the start of the file.
00267 
00268            Next, the range of lines in file2 shall be written in the following format
00269            if the range contains two or more lines:
00270                "--- %d,%d ----\n", <beginning line number>, <ending line number>
00271            and the following format otherwise:
00272                "--- %d ----\n", <ending line number>
00273         '''
00274         fmt = difflib._format_range_context
00275         self.assertEqual(fmt(3,3), '3')
00276         self.assertEqual(fmt(3,4), '4')
00277         self.assertEqual(fmt(3,5), '4,5')
00278         self.assertEqual(fmt(3,6), '4,6')
00279         self.assertEqual(fmt(0,0), '0')
00280 

Here is the call graph for this function:

Definition at line 239 of file test_difflib.py.

00239 
00240     def test_range_format_unified(self):
00241         # Per the diff spec at http://www.unix.org/single_unix_specification/
00242         spec = '''\
00243            Each <range> field shall be of the form:
00244              %1d", <beginning line number>  if the range contains exactly one line,
00245            and:
00246             "%1d,%1d", <beginning line number>, <number of lines> otherwise.
00247            If a range is empty, its beginning line number shall be the number of
00248            the line just before the range, or 0 if the empty range starts the file.
00249         '''
00250         fmt = difflib._format_range_unified
00251         self.assertEqual(fmt(3,3), '3,0')
00252         self.assertEqual(fmt(3,4), '4')
00253         self.assertEqual(fmt(3,5), '4,2')
00254         self.assertEqual(fmt(3,6), '4,3')
00255         self.assertEqual(fmt(0,0), '0,0')

Here is the call graph for this function:

Definition at line 219 of file test_difflib.py.

00219 
00220     def test_tab_delimiter(self):
00221         args = ['one', 'two', 'Original', 'Current',
00222             '2005-01-26 23:30:50', '2010-04-02 10:20:52']
00223         ud = difflib.unified_diff(*args, lineterm='')
00224         self.assertEqual(list(ud)[0:2], [
00225                            "--- Original\t2005-01-26 23:30:50",
00226                            "+++ Current\t2010-04-02 10:20:52"])
00227         cd = difflib.context_diff(*args, lineterm='')
00228         self.assertEqual(list(cd)[0:2], [
00229                            "*** Original\t2005-01-26 23:30:50",
00230                            "--- Current\t2010-04-02 10:20:52"])

Here is the call graph for this function:


The documentation for this class was generated from the following file: