diff -r 194f74044537 Lib/test/filecmpdata/full-dirs/dir-diff/file --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-dirs/dir-diff/file Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-dirs/dir-diff/file2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-dirs/dir-diff/file2 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +An extra file. diff -r 194f74044537 Lib/test/filecmpdata/full-dirs/dir-diff/subdir-diff/file3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-dirs/dir-diff/subdir-diff/file3 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-dirs/dir-diff/subdir/file3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-dirs/dir-diff/subdir/file3 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-dirs/dir-diff/subdir/file4 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-dirs/dir-diff/subdir/file4 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +An extra file. diff -r 194f74044537 Lib/test/filecmpdata/full-dirs/dir-diff/subdir/nested-diff/file5 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-dirs/dir-diff/subdir/nested-diff/file5 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-dirs/dir-diff/subdir/nested/file5 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-dirs/dir-diff/subdir/nested/file5 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-dirs/dir-diff/subdir/nested/file6 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-dirs/dir-diff/subdir/nested/file6 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +An extra file. diff -r 194f74044537 Lib/test/filecmpdata/full-dirs/dir-same/file --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-dirs/dir-same/file Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-dirs/dir-same/subdir/file3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-dirs/dir-same/subdir/file3 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-dirs/dir-same/subdir/nested/file5 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-dirs/dir-same/subdir/nested/file5 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-dirs/dir/file --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-dirs/dir/file Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-dirs/dir/subdir/file3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-dirs/dir/subdir/file3 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-dirs/dir/subdir/nested/file5 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-dirs/dir/subdir/nested/file5 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-files/dir-diff/file --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-files/dir-diff/file Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-files/dir-diff/file2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-files/dir-diff/file2 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +An extra file. diff -r 194f74044537 Lib/test/filecmpdata/full-files/dir-diff/subdir-diff/file3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-files/dir-diff/subdir-diff/file3 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-files/dir-diff/subdir/file3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-files/dir-diff/subdir/file3 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-files/dir-diff/subdir/file4 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-files/dir-diff/subdir/file4 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +An extra file. diff -r 194f74044537 Lib/test/filecmpdata/full-files/dir-diff/subdir/nested-diff/file5 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-files/dir-diff/subdir/nested-diff/file5 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-files/dir-diff/subdir/nested/file5 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-files/dir-diff/subdir/nested/file5 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-files/dir-diff/subdir/nested/file6 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-files/dir-diff/subdir/nested/file6 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Different contents. diff -r 194f74044537 Lib/test/filecmpdata/full-files/dir/file --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-files/dir/file Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-files/dir/subdir/file3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-files/dir/subdir/file3 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-files/dir/subdir/nested/file5 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-files/dir/subdir/nested/file5 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/full-files/dir/subdir/nested/file6 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/full-files/dir/subdir/nested/file6 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +An extra file. diff -r 194f74044537 Lib/test/filecmpdata/partial-dirs/dir-diff/file --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/partial-dirs/dir-diff/file Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/partial-dirs/dir-diff/file2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/partial-dirs/dir-diff/file2 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +An extra file. diff -r 194f74044537 Lib/test/filecmpdata/partial-dirs/dir-diff/subdir-diff/file3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/partial-dirs/dir-diff/subdir-diff/file3 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/partial-dirs/dir-diff/subdir/file3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/partial-dirs/dir-diff/subdir/file3 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/partial-dirs/dir-diff/subdir/file4 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/partial-dirs/dir-diff/subdir/file4 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +An extra file. diff -r 194f74044537 Lib/test/filecmpdata/partial-dirs/dir-same/file --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/partial-dirs/dir-same/file Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/partial-dirs/dir-same/subdir/file3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/partial-dirs/dir-same/subdir/file3 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/partial-dirs/dir/file --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/partial-dirs/dir/file Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/partial-dirs/dir/subdir/file3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/partial-dirs/dir/subdir/file3 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/partial-files/dir-diff/file --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/partial-files/dir-diff/file Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/partial-files/dir-diff/file2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/partial-files/dir-diff/file2 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +An extra file. diff -r 194f74044537 Lib/test/filecmpdata/partial-files/dir-diff/subdir-diff/file3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/partial-files/dir-diff/subdir-diff/file3 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/partial-files/dir-diff/subdir/file3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/partial-files/dir-diff/subdir/file3 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/partial-files/dir-diff/subdir/file4 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/partial-files/dir-diff/subdir/file4 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Different contents. diff -r 194f74044537 Lib/test/filecmpdata/partial-files/dir/file --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/partial-files/dir/file Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/partial-files/dir/subdir/file3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/partial-files/dir/subdir/file3 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/partial-files/dir/subdir/file4 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/partial-files/dir/subdir/file4 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +An extra file. diff -r 194f74044537 Lib/test/filecmpdata/report-dirs/dir-diff/file --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/report-dirs/dir-diff/file Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/report-dirs/dir-diff/file2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/report-dirs/dir-diff/file2 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +An extra file. diff -r 194f74044537 Lib/test/filecmpdata/report-dirs/dir-same/file --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/report-dirs/dir-same/file Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/report-dirs/dir/file --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/report-dirs/dir/file Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/report-files/dir-diff/file --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/report-files/dir-diff/file Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/report-files/dir-diff/file2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/report-files/dir-diff/file2 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Different contents. diff -r 194f74044537 Lib/test/filecmpdata/report-files/dir/file --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/report-files/dir/file Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +Contents of file go here. diff -r 194f74044537 Lib/test/filecmpdata/report-files/dir/file2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/filecmpdata/report-files/dir/file2 Tue Dec 03 20:21:52 2013 -0500 @@ -0,0 +1,1 @@ +An extra file. diff -r 194f74044537 Lib/test/test_filecmp.py --- a/Lib/test/test_filecmp.py Wed Dec 04 01:29:35 2013 +0100 +++ b/Lib/test/test_filecmp.py Tue Dec 03 20:21:52 2013 -0500 @@ -146,8 +146,727 @@ self.assertEqual(d.diff_files, ['file2']) +class BaseReportTestCase(unittest.TestCase): + """Common attributes for report test cases. + + Test data for the three filecmp.dircmp report methods are predefined + in cpython/Lib/test/filecmpdata. + + The report methods cover three use cases: + + 1. Comparing files in two directories (filecmp.dircmp.report), + 2. Comparing files in two directories and their immediate subdirectories + (filecmp.dircmp.report_partial_closure), and + 3. Comparing files in two directories and their subdirectories recursively + (filecmp.dircmp.report_full_closure). + + There are three basic tests for each report method: + + 1. The directories have the same files with the same contents, + 2. The directories have some files with different names or + files that exist in only one of the directories, and + 3. The directories have files by the same name but with different contents. + + In order to test comparing files in two directories + (filecmp.dircmp.report), the filecmpdata test data + contains two directories: + + 1. report-dirs, containing two identical subdirectories and another with an + additional file:: + + filecmpdata + +-- report-dirs + +-- dir + |   +-- file + +-- dir-same + | +-- file (same contents as dir/file) + +-- dir-diff + +-- file (same contents as dir/file) + +-- file2 (extra file) + + 2. report-files, containing two subdirectories with differeing files:: + + filecmpdata + +-- report-files + +-- dir + |   +-- file + |   +-- file2 + +-- dir-diff + +-- file (same contents as dir/file) + +-- file2 (different contents than dir/file2) + + In order to test comparing files in two directories and their immediate + subdirectories (filecmp.dircmp.report_partial_closure), the filecmpdata + test data contains two directories: + + 1. partial-dirs, containing two identical subdirectories and another with + an additional file, an additional file in a subdirectory, and an + additional subdirectory:: + + filecmpdata + +-- partial-dirs +    +-- dir +    |   +-- file +    |   +-- subdir +    |   +-- file3 +    +-- dir-same +    | +-- file (same contents as dir/file) +    | +-- subdir +    | +-- file3 (same contents as dir/subdir/file3) +    +-- dir-diff +       +-- file +       +-- file2 (extra file) +       +-- subdir +       |   +-- file3 (same contents as dir/subdir/file3) +       |   +-- file4 (extra file) +       +-- subdir-diff (extra subdirectory) +       +-- file3 (same contents as dir/subdir/file3) + + 2. partial-files, containing two subdirectories, one with an additional + file, both with subdirectories where one contains a differing file, + and one with an additional subdirectory:: + + filecmpdata + +-- partial-files +    +-- dir +    |   +-- file +    |   +-- subdir +    |   +-- file3 +    |   +-- file4 +    +-- dir-diff +    +-- file (same contents as dir/file) +    +-- file2 (extra file) +    +-- subdir +    |   +-- file3 (same contents as dir/subdir/file3) +    |   +-- file4 (different contents than dir/subdir/file4) +    +-- subdir-diff (extra subdirectory) +    +-- file3 (same contents as dir/subdir/file3) + + In order to test comparing files in two directories and their + subdirectories (filecmp.dircmp.report_full_closure), the filecmpdata + test data contains two directories: + + 1. full-dirs, containing two identical nested subdirectories and another + with an additional file, additional files in a subdirectory and + nested subdirectory, and an additional subdirectory and nested + subdirectory:: + + filecmpdata + +-- full-dirs +    +-- dir +    |   +-- file +    |   +-- subdir +    |   +-- file3 +    |   +-- nested +    |   +-- file5 +    +-- dir-same +    | +-- file (same contents as dir/file) +    | +-- subdir +    | +-- file3 +    | +-- nested (same contents as dir/subdir/file3) +    | +-- file5 (same contents as dir/subdir/nested/file5) +    +-- dir-diff +       +-- file (same contents as dir/file) +       +-- file2 (extra file) +       +-- subdir +       |   +-- file3 (same contents as dir/subdir/file3) +       |   +-- file4 (extra file) +       |   +-- nested +       |   |   +-- file5 (same contents as dir/subdir/nested/file5) +       |   |   +-- file6 (extra file) +       |   +-- nested-diff (extra nested subdirectory) +       |   +-- file5 (same contents as dir/subdir/nested/file5) +       +-- subdir-diff (extra subdirectory) +       +-- file3 (same contents as dir/subdir/file3) + + 2. full-files, containing two nested subdirectories, one with an + additional file, an additional file in a subdirectory, an additional + subdirectory, a differing file in a nested subdirectory, an additional + nested subdirectory:: + + filecmpdata + +-- full-files + +-- dir + |   +-- file + |   +-- subdir + |   +-- file3 + |   +-- nested + |   +-- file5 + |   +-- file6 + +-- dir-diff + +-- file (same contents as dir/file) + +-- file2 (extra file) + +-- subdir + |   +-- file3 (same contents as dir/subdir/file3) + |   +-- file4 (extra file) + |   +-- nested + |   |   +-- file5 (same contents as dir/subdir/nested/file5) + |   |   +-- file6 (different contents than + | | dir/subdir/nested/file6) + |   +-- nested-diff (extra nested subdirectory) + |   +-- file5 (same contents as dir/subdir/nested/file5) + +-- subdir-diff (extra subdirectory) + +-- file3 (same contents as dir/subdir/file3) + """ + + TEST_DATA = 'filecmpdata' + + REPORT_DIRS = 'report-dirs' + REPORT_FILES = 'report-files' + PARTIAL_DIRS = 'partial-dirs' + PARTIAL_FILES = 'partial-files' + FULL_DIRS = 'full-dirs' + FULL_FILES = 'full-files' + + DIR = 'dir' + SAME = 'dir-same' + DIFF = 'dir-diff' + SUBDIR = 'subdir' + SDIFF = 'subdir-diff' + NESTED = 'nested' + NDIFF = 'nested-diff' + + FILE = 'file' + EXTRA = 'file2' + SFILE = 'file3' + SEXTRA = 'file4' + NFILE = 'file5' + NEXTRA = 'file6' + + test_data = support.findfile(TEST_DATA) + + report_dir = os.path.join(test_data, REPORT_DIRS) + report_files = os.path.join(test_data, REPORT_FILES) + partial_dir = os.path.join(test_data, PARTIAL_DIRS) + partial_files = os.path.join(test_data, PARTIAL_FILES) + full_dir = os.path.join(test_data, FULL_DIRS) + full_files = os.path.join(test_data, FULL_FILES) + + dir_subdir = os.path.join(DIR, SUBDIR) + same_subdir = os.path.join(SAME, SUBDIR) + diff_subdir = os.path.join(DIFF, SUBDIR) + + dir_nested = os.path.join(dir_subdir, NESTED) + same_nested = os.path.join(same_subdir, NESTED) + diff_nested = os.path.join(diff_subdir, NESTED) + + def setUpPaths(self): + """ + Set up paths required for complete test coverage. + + Implemented in subclasses. + """ + + pass + + def setUpReports(self): + """ + Set up reports expected by tests. + + Implemented in subclasses. + """ + + pass + + def setUp(self): + self.setUpPaths() + self.setUpReports() + + +class ReportTestCase(BaseReportTestCase): + """ + Test reports in directory. + """ + + def setUpPaths(self): + """Set up paths required for complete test coverage.""" + + self.dirs_dir = os.path.join(self.report_dir, self.DIR) + self.dirs_same = os.path.join(self.report_dir, self.SAME) + self.dirs_diff = os.path.join(self.report_dir, self.DIFF) + self.files_dir = os.path.join(self.report_files, self.DIR) + self.files_diff = os.path.join(self.report_files, self.DIFF) + + def setUpReports(self): + """Set up reports expected by tests.""" + + self.report_same = "\n".join(( + "diff {0.dirs_dir} {0.dirs_same}", + "Identical files : ['{0.FILE}']", + "",)).format(self) + self.report_diff_dirs = "\n".join(( + "diff {0.dirs_dir} {0.dirs_diff}", + "Only in {0.dirs_diff} : ['{0.EXTRA}']", + "Identical files : ['{0.FILE}']", + "",)).format(self) + self.report_diff_files = "\n".join(( + "diff {0.files_dir} {0.files_diff}", + "Identical files : ['{0.FILE}']", + "Differing files : ['{0.EXTRA}']", + "",)).format(self) + + def test_report_same(self): + """Test report with two identical directories.""" + + d = filecmp.dircmp(self.dirs_dir, self.dirs_same) + with support.captured_stdout() as r: + d.report() + self.assertEqual(r.getvalue(), self.report_same, + "Comparing identical directories fails.") + + def test_report_different_dirs(self): + """Test report with different directories.""" + + d = filecmp.dircmp(self.dirs_dir, self.dirs_diff) + with support.captured_stdout() as r: + d.report() + self.assertEqual(r.getvalue(), self.report_diff_dirs, + "Comparing different directories fails.") + + def test_report_different_files(self): + """Test report with different files in directories.""" + + d = filecmp.dircmp(self.files_dir, self.files_diff) + with support.captured_stdout() as r: + d.report() + self.assertEqual(r.getvalue(), self.report_diff_files, + "Comparing different files in directories fails.") + + def test_partial_report_same(self): + """Test partial report with two identical directories.""" + + d = filecmp.dircmp(self.dirs_dir, self.dirs_same) + with support.captured_stdout() as r: + d.report_partial_closure() + self.assertEqual(r.getvalue(), self.report_same, + "Partially comparing identical directories fails.") + + def test_partial_report_different_dirs(self): + """Test partial report with different directories.""" + + d = filecmp.dircmp(self.dirs_dir, self.dirs_diff) + with support.captured_stdout() as r: + d.report_partial_closure() + self.assertEqual(r.getvalue(), self.report_diff_dirs, + "Partially comparing different directories fails.") + + def test_partial_report_different_files(self): + """Test partial report with different files in directories.""" + + d = filecmp.dircmp(self.files_dir, self.files_diff) + with support.captured_stdout() as r: + d.report_partial_closure() + self.assertEqual( + r.getvalue(), self.report_diff_files, + "Partially comparing different files in directories fails.") + + def test_full_report_same(self): + """Test full report with two identical directories.""" + + d = filecmp.dircmp(self.dirs_dir, self.dirs_same) + with support.captured_stdout() as r: + d.report_full_closure() + self.assertEqual(r.getvalue(), self.report_same, + "Fully comparing identical directories fails.") + + def test_full_report_different_dirs(self): + """Test full report with different directories.""" + + d = filecmp.dircmp(self.dirs_dir, self.dirs_diff) + with support.captured_stdout() as r: + d.report_full_closure() + self.assertEqual(r.getvalue(), self.report_diff_dirs, + "Fully comparing different directories fails.") + + def test_full_report_different_files(self): + """Test full report with different files in directories.""" + + d = filecmp.dircmp(self.files_dir, self.files_diff) + with support.captured_stdout() as r: + d.report_full_closure() + self.assertEqual( + r.getvalue(), self.report_diff_files, + "Fully comparing different files in directories fails.") + + +class PartialReportTestCase(BaseReportTestCase): + """ + Test reports in subdirectory. + """ + + def setUpPaths(self): + """Set up paths required for complete test coverage.""" + + self.dirs_dir = os.path.join(self.partial_dir, self.DIR) + self.dirs_same = os.path.join(self.partial_dir, self.SAME) + self.dirs_diff = os.path.join(self.partial_dir, self.DIFF) + self.files_dir = os.path.join(self.partial_files, self.DIR) + self.files_diff = os.path.join(self.partial_files, self.DIFF) + + self.dirs_dir_subdir = os.path.join(self.partial_dir, self.dir_subdir) + self.dirs_same_subdir = os.path.join(self.partial_dir, + self.same_subdir) + self.dirs_diff_subdir = os.path.join(self.partial_dir, + self.diff_subdir) + self.files_dir_subdir = os.path.join(self.partial_files, + self.dir_subdir) + self.files_diff_subdir = os.path.join(self.partial_files, + self.diff_subdir) + + def setUpReports(self): + """Set up reports expected by tests.""" + + self.report_same = "\n".join(( + "diff {0.dirs_dir} {0.dirs_same}", + "Identical files : ['{0.FILE}']", + "Common subdirectories : ['{0.SUBDIR}']", + "",)).format(self) + self.report_diff_dirs = "\n".join(( + "diff {0.dirs_dir} {0.dirs_diff}", + "Only in {0.dirs_diff} : ['{0.EXTRA}', '{0.SDIFF}']", + "Identical files : ['{0.FILE}']", + "Common subdirectories : ['{0.SUBDIR}']", + "",)).format(self) + self.report_diff_files = "\n".join(( + "diff {0.files_dir} {0.files_diff}", + "Only in {0.files_diff} : ['{0.EXTRA}', '{0.SDIFF}']", + "Identical files : ['{0.FILE}']", + "Common subdirectories : ['{0.SUBDIR}']", + "",)).format(self) + self.partial_report_same = "\n".join(( + "diff {0.dirs_dir} {0.dirs_same}", + "Identical files : ['{0.FILE}']", + "Common subdirectories : ['{0.SUBDIR}']", + "", + "diff {0.dirs_dir_subdir} {0.dirs_same_subdir}", + "Identical files : ['{0.SFILE}']", + "",)).format(self) + self.partial_report_diff_dirs = "\n".join(( + "diff {0.dirs_dir} {0.dirs_diff}", + "Only in {0.dirs_diff} : ['{0.EXTRA}', '{0.SDIFF}']", + "Identical files : ['{0.FILE}']", + "Common subdirectories : ['{0.SUBDIR}']", + "", + "diff {0.dirs_dir_subdir} {0.dirs_diff_subdir}", + "Only in {0.dirs_diff_subdir} : ['{0.SEXTRA}']", + "Identical files : ['{0.SFILE}']", + "",)).format(self) + self.partial_report_diff_files = "\n".join(( + "diff {0.files_dir} {0.files_diff}", + "Only in {0.files_diff} : ['{0.EXTRA}', '{0.SDIFF}']", + "Identical files : ['{0.FILE}']", + "Common subdirectories : ['{0.SUBDIR}']", + "", + "diff {0.files_dir_subdir} {0.files_diff_subdir}", + "Identical files : ['{0.SFILE}']", + "Differing files : ['{0.SEXTRA}']", + "",)).format(self) + + def test_report_same(self): + """Test report with two identical subdirectories.""" + + d = filecmp.dircmp(self.dirs_dir, self.dirs_same) + with support.captured_stdout() as r: + d.report() + self.assertEqual(r.getvalue(), self.report_same, + "Comparing identical subdirectories fails.") + + def test_report_different_dirs(self): + """Test report with different subdirectories.""" + + d = filecmp.dircmp(self.dirs_dir, self.dirs_diff) + with support.captured_stdout() as r: + d.report() + self.assertEqual(r.getvalue(), self.report_diff_dirs, + "Comparing different subdirectories fails.") + + def test_report_different_files(self): + """Test report with different files in subdirectories.""" + + d = filecmp.dircmp(self.files_dir, self.files_diff) + with support.captured_stdout() as r: + d.report() + self.assertEqual(r.getvalue(), self.report_diff_files, + "Comparing different files in subdirectories fails.") + + def test_partial_report_same(self): + """Test partial report with two identical subdirectories.""" + + d = filecmp.dircmp(self.dirs_dir, self.dirs_same) + with support.captured_stdout() as r: + d.report_partial_closure() + self.assertEqual(r.getvalue(), self.partial_report_same, + "Partially comparing identical subdirectories fails.") + + def test_partial_report_different_dirs(self): + """Test partial report with different subdirectories.""" + + d = filecmp.dircmp(self.dirs_dir, self.dirs_diff) + with support.captured_stdout() as r: + d.report_partial_closure() + self.assertEqual(r.getvalue(), self.partial_report_diff_dirs, + "Partially comparing different subdirectories fails.") + + def test_partial_report_different_files(self): + """Test partial report with different files in subdirectories.""" + + d = filecmp.dircmp(self.files_dir, self.files_diff) + with support.captured_stdout() as r: + d.report_partial_closure() + self.assertEqual( + r.getvalue(), self.partial_report_diff_files, + "Partially comparing different files in subdirectories fails.") + + def test_full_report_same(self): + """Test full report with two identical subdirectories.""" + + d = filecmp.dircmp(self.dirs_dir, self.dirs_same) + with support.captured_stdout() as r: + d.report_full_closure() + self.assertEqual(r.getvalue(), self.partial_report_same, + "Fully comparing identical subdirectories fails.") + + def test_full_report_different_dirs(self): + """Test full report with different subdirectories.""" + + d = filecmp.dircmp(self.dirs_dir, self.dirs_diff) + with support.captured_stdout() as r: + d.report_full_closure() + self.assertEqual(r.getvalue(), self.partial_report_diff_dirs, + "Fully comparing different subdirectories fails.") + + def test_full_report_different_files(self): + """Test full report with different files in subdirectories.""" + + d = filecmp.dircmp(self.files_dir, self.files_diff) + with support.captured_stdout() as r: + d.report_full_closure() + self.assertEqual( + r.getvalue(), self.partial_report_diff_files, + "Fully comparing different files in subdirectories fails.") + + +class FullReportTestCase(BaseReportTestCase): + """ + Test reports in nested subdirectory. + """ + + def setUpPaths(self): + """Set up paths required for complete test coverage.""" + + self.dirs_dir = os.path.join(self.full_dir, self.DIR) + self.dirs_same = os.path.join(self.full_dir, self.SAME) + self.dirs_diff = os.path.join(self.full_dir, self.DIFF) + self.files_dir = os.path.join(self.full_files, self.DIR) + self.files_diff = os.path.join(self.full_files, self.DIFF) + + self.dirs_dir_subdir = os.path.join(self.full_dir, self.dir_subdir) + self.dirs_same_subdir = os.path.join(self.full_dir, self.same_subdir) + self.dirs_diff_subdir = os.path.join(self.full_dir, self.diff_subdir) + self.files_dir_subdir = os.path.join(self.full_files, self.dir_subdir) + self.files_diff_subdir = os.path.join(self.full_files, + self.diff_subdir) + + self.dirs_dir_nested = os.path.join(self.full_dir, self.dir_nested) + self.dirs_same_nested = os.path.join(self.full_dir, self.same_nested) + self.dirs_diff_nested = os.path.join(self.full_dir, self.diff_nested) + self.files_dir_nested = os.path.join(self.full_files, self.dir_nested) + self.files_diff_nested = os.path.join(self.full_files, + self.diff_nested) + + def setUpReports(self): + """Set up reports expected by tests.""" + + self.report_same = "\n".join(( + "diff {0.dirs_dir} {0.dirs_same}", + "Identical files : ['{0.FILE}']", + "Common subdirectories : ['{0.SUBDIR}']", + "",)).format(self) + self.report_diff_dirs = "\n".join(( + "diff {0.dirs_dir} {0.dirs_diff}", + "Only in {0.dirs_diff} : ['{0.EXTRA}', '{0.SDIFF}']", + "Identical files : ['{0.FILE}']", + "Common subdirectories : ['{0.SUBDIR}']", + "",)).format(self) + self.report_diff_files = "\n".join(( + "diff {0.files_dir} {0.files_diff}", + "Only in {0.files_diff} : ['{0.EXTRA}', '{0.SDIFF}']", + "Identical files : ['{0.FILE}']", + "Common subdirectories : ['{0.SUBDIR}']", + "",)).format(self) + self.partial_report_same = "\n".join(( + "diff {0.dirs_dir} {0.dirs_same}", + "Identical files : ['{0.FILE}']", + "Common subdirectories : ['{0.SUBDIR}']", + "", + "diff {0.dirs_dir_subdir} {0.dirs_same_subdir}", + "Identical files : ['{0.SFILE}']", + "Common subdirectories : ['{0.NESTED}']", + "",)).format(self) + self.partial_report_diff_dirs = "\n".join(( + "diff {0.dirs_dir} {0.dirs_diff}", + "Only in {0.dirs_diff} : ['{0.EXTRA}', '{0.SDIFF}']", + "Identical files : ['{0.FILE}']", + "Common subdirectories : ['{0.SUBDIR}']", + "", + "diff {0.dirs_dir_subdir} {0.dirs_diff_subdir}", + "Only in {0.dirs_diff_subdir} : ['{0.SEXTRA}', '{0.NDIFF}']", + "Identical files : ['{0.SFILE}']", + "Common subdirectories : ['{0.NESTED}']", + "",)).format(self) + self.partial_report_diff_files = "\n".join(( + "diff {0.files_dir} {0.files_diff}", + "Only in {0.files_diff} : ['{0.EXTRA}', '{0.SDIFF}']", + "Identical files : ['{0.FILE}']", + "Common subdirectories : ['{0.SUBDIR}']", + "", + "diff {0.files_dir_subdir} {0.files_diff_subdir}", + "Only in {0.files_diff_subdir} : ['{0.SEXTRA}', '{0.NDIFF}']", + "Identical files : ['{0.SFILE}']", + "Common subdirectories : ['{0.NESTED}']", + "",)).format(self) + self.full_report_same = "\n".join(( + "diff {0.dirs_dir} {0.dirs_same}", + "Identical files : ['{0.FILE}']", + "Common subdirectories : ['{0.SUBDIR}']", + "", + "diff {0.dirs_dir_subdir} {0.dirs_same_subdir}", + "Identical files : ['{0.SFILE}']", + "Common subdirectories : ['{0.NESTED}']", + "", + "diff {0.dirs_dir_nested} {0.dirs_same_nested}", + "Identical files : ['{0.NFILE}']", + "",)).format(self) + self.full_report_diff_dirs = "\n".join(( + "diff {0.dirs_dir} {0.dirs_diff}", + "Only in {0.dirs_diff} : ['{0.EXTRA}', '{0.SDIFF}']", + "Identical files : ['{0.FILE}']", + "Common subdirectories : ['{0.SUBDIR}']", + "", + "diff {0.dirs_dir_subdir} {0.dirs_diff_subdir}", + "Only in {0.dirs_diff_subdir} : ['{0.SEXTRA}', '{0.NDIFF}']", + "Identical files : ['{0.SFILE}']", + "Common subdirectories : ['{0.NESTED}']", + "", + "diff {0.dirs_dir_nested} {0.dirs_diff_nested}", + "Only in {0.dirs_diff_nested} : ['{0.NEXTRA}']", + "Identical files : ['{0.NFILE}']", + "",)).format(self) + self.full_report_diff_files = "\n".join(( + "diff {0.files_dir} {0.files_diff}", + "Only in {0.files_diff} : ['{0.EXTRA}', '{0.SDIFF}']", + "Identical files : ['{0.FILE}']", + "Common subdirectories : ['{0.SUBDIR}']", + "", + "diff {0.files_dir_subdir} {0.files_diff_subdir}", + "Only in {0.files_diff_subdir} : ['{0.SEXTRA}', '{0.NDIFF}']", + "Identical files : ['{0.SFILE}']", + "Common subdirectories : ['{0.NESTED}']", + "", + "diff {0.files_dir_nested} {0.files_diff_nested}", + "Identical files : ['{0.NFILE}']", + "Differing files : ['{0.NEXTRA}']", + "",)).format(self) + + def test_report_same(self): + """Test report with two identical nested subdirectories.""" + + d = filecmp.dircmp(self.dirs_dir, self.dirs_same) + with support.captured_stdout() as r: + d.report() + self.assertEqual(r.getvalue(), self.report_same, + "Comparing identical nested subdirectories fails.") + + def test_report_different_dirs(self): + """Test report with different nested subdirectories.""" + + d = filecmp.dircmp(self.dirs_dir, self.dirs_diff) + with support.captured_stdout() as r: + d.report() + self.assertEqual(r.getvalue(), self.report_diff_dirs, + "Comparing different nested subdirectories fails.") + + def test_report_different_files(self): + """Test report with different files in nested subdirectories.""" + + d = filecmp.dircmp(self.files_dir, self.files_diff) + with support.captured_stdout() as r: + d.report() + self.assertEqual( + r.getvalue(), self.report_diff_files, + "Comparing different files in nested subdirectories fails.") + + def test_partial_report_same(self): + """Test partial report with two identical nested subdirectories.""" + + d = filecmp.dircmp(self.dirs_dir, self.dirs_same) + with support.captured_stdout() as r: + d.report_partial_closure() + self.assertEqual( + r.getvalue(), self.partial_report_same, + "Partially comparing identical nested subdirectories fails.") + + def test_partial_report_different_dirs(self): + """Test partial report with different nested subdirectories.""" + + d = filecmp.dircmp(self.dirs_dir, self.dirs_diff) + with support.captured_stdout() as r: + d.report_partial_closure() + self.assertEqual( + r.getvalue(), self.partial_report_diff_dirs, + "Partially comparing different nested subdirectories fails.") + + def test_partial_report_different_files(self): + """ + Test partial report with different files in nested subdirectories. + """ + + d = filecmp.dircmp(self.files_dir, self.files_diff) + with support.captured_stdout() as r: + d.report_partial_closure() + self.assertEqual( + r.getvalue(), self.partial_report_diff_files, + "Partially comparing different files in " + "nested subdirectories fails.") + + def test_full_report_same(self): + """Test full report with two identical nested subdirectories.""" + + d = filecmp.dircmp(self.dirs_dir, self.dirs_same) + with support.captured_stdout() as r: + d.report_full_closure() + self.assertEqual( + r.getvalue(), self.full_report_same, + "Fully comparing identical nested subdirectories fails.") + + def test_full_report_different_dirs(self): + """Test full report with different nested subdirectories.""" + + d = filecmp.dircmp(self.dirs_dir, self.dirs_diff) + with support.captured_stdout() as r: + d.report_full_closure() + self.assertEqual( + r.getvalue(), self.full_report_diff_dirs, + "Fully comparing different nested subdirectories fails.") + + def test_full_report_different_files(self): + """Test full report with different files in nested subdirectories.""" + + d = filecmp.dircmp(self.files_dir, self.files_diff) + with support.captured_stdout() as r: + d.report_full_closure() + self.assertEqual( + r.getvalue(), self.full_report_diff_files, + "Fully comparing different files in " + "nested subdirectories fails.") + + def test_main(): - support.run_unittest(FileCompareTestCase, DirCompareTestCase) + support.run_unittest(FileCompareTestCase, + DirCompareTestCase, + ReportTestCase, + PartialReportTestCase, + FullReportTestCase) if __name__ == "__main__": test_main()