~ubuntu-branches/ubuntu/jaunty/python-docutils/jaunty

« back to all changes in this revision

Viewing changes to test/functional/tests/standalone_rst_s5_html_1.py

  • Committer: Bazaar Package Importer
  • Author(s): martin f. krafft
  • Date: 2006-07-10 11:45:05 UTC
  • mfrom: (2.1.4 edgy)
  • Revision ID: james.westby@ubuntu.com-20060710114505-otkhqcslevewxmz5
Tags: 0.4-3
Added build dependency on python-central (closes: #377580).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
execfile('functional/tests/_standalone_rst_defaults.py')
 
2
 
 
3
# Source and destination file names:
 
4
test_source = 'standalone_rst_s5_html.txt'
 
5
test_destination = 'standalone_rst_s5_html_1.html'
 
6
 
 
7
# Keyword parameters passed to publish_file:
 
8
writer_name = 's5_html'
 
9
 
 
10
# Settings:
 
11
settings_overrides['theme'] = 'small-black'
 
12
 
 
13
 
 
14
# Extra functional tests.
 
15
# Prefix all names with '_' to avoid confusing `docutils.core.publish_file`.
 
16
 
 
17
import filecmp as _filecmp
 
18
 
 
19
def _test_more(expected_dir, output_dir, test_case, parameters):
 
20
    """Compare ``ui/<theme>`` directories."""
 
21
    theme = settings_overrides.get('theme', 'default')
 
22
    expected = '%s/%s/%s' % (expected_dir, 'ui', theme)
 
23
    output = '%s/%s/%s' % (output_dir, 'ui', theme)
 
24
    differences, uniques = _compare_directories(expected, output)
 
25
    parts = []
 
26
    if differences:
 
27
        parts.append('The following files differ from the expected output:')
 
28
        parts.extend(differences)
 
29
        expected = [path.replace('functional/output/', 'functional/expected/')
 
30
                    for path in differences]
 
31
        parts.append('Please compare the expected and actual output files:')
 
32
        parts.extend(['  diff %s %s' % tup
 
33
                      for tup in zip(expected, differences)])
 
34
        parts.append('If the actual output is correct, please replace the '
 
35
                     'expected output files:')
 
36
        parts.extend(['  mv %s %s' % tup
 
37
                      for tup in zip(differences, expected)])
 
38
        parts.append('and check them in to Subversion:')
 
39
        parts.extend(['  svn commit -m "<comment>" %s' % path
 
40
                      for path in expected])
 
41
    if uniques:
 
42
        parts.append('The following paths are unique:')
 
43
        parts.extend(uniques)
 
44
    test_case.assert_(not parts, '\n'.join(parts))
 
45
 
 
46
def _compare_directories(expected, output):
 
47
    dircmp = _filecmp.dircmp(expected, output, ['.svn', 'CVS'])
 
48
    differences = ['%s/%s' % (output, name) for name in dircmp.diff_files]
 
49
    uniques = (['%s/%s' % (expected, name) for name in dircmp.left_only]
 
50
               + ['%s/%s' % (output, name) for name in dircmp.right_only])
 
51
    for subdir in dircmp.common_dirs:
 
52
        diffs, uniqs = _compare_directories('%s/%s' % (expected, subdir),
 
53
                                            '%s/%s' % (output, subdir))
 
54
        differences.extend(diffs)
 
55
        uniques.extend(uniqs)
 
56
    return differences, uniques