~ubuntu-branches/ubuntu/karmic/python-docutils/karmic

« back to all changes in this revision

Viewing changes to test/test_settings.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:
2
2
 
3
3
# Author: David Goodger
4
4
# Contact: goodger@python.org
5
 
# Revision:  $Revision: 1.5 $
6
 
# Date:      $Date: 2004/05/07 15:17:17 $
 
5
# Revision:  $Revision: 4222 $
 
6
# Date:      $Date: 2005-12-16 00:47:54 +0100 (Fri, 16 Dec 2005) $
7
7
# Copyright: This module has been placed in the public domain.
8
8
 
9
9
"""
12
12
 
13
13
import sys
14
14
import os
15
 
import difflib
 
15
import docutils_difflib
16
16
import pprint
17
17
import warnings
18
18
import unittest
19
 
from docutils import frontend
20
 
from docutils.writers import html4css1
21
 
from docutils.writers import pep_html
 
19
from types import StringType
 
20
import DocutilsTestSupport              # must be imported before docutils
 
21
from docutils import frontend, utils
 
22
from docutils.writers import html4css1, pep_html
 
23
from docutils.parsers import rst
22
24
 
23
25
 
24
26
warnings.filterwarnings(action='ignore',
25
27
                        category=frontend.ConfigDeprecationWarning)
26
28
 
27
29
def fixpath(path):
28
 
    return os.path.abspath(os.path.join(mydir, path))
29
 
 
30
 
mydir = os.path.dirname(fixpath.func_code.co_filename)
 
30
    return os.path.abspath(os.path.join(*(path.split('/'))))
31
31
 
32
32
 
33
33
class ConfigFileTests(unittest.TestCase):
45
45
                'no_random': 1,
46
46
                'python_home': 'http://www.python.org',
47
47
                'source_link': 1,
 
48
                'stylesheet': None,
48
49
                'stylesheet_path': fixpath('data/stylesheets/pep.css'),
49
50
                'template': fixpath('data/pep-html-template')},
50
51
        'one': {'datestamp': '%Y-%m-%d %H:%M UTC',
51
52
                'generator': 1,
52
53
                'no_random': 1,
53
54
                'python_home': 'http://www.python.org',
 
55
                'record_dependencies': utils.DependencyList(),
54
56
                'source_link': 1,
 
57
                'stylesheet': None,
55
58
                'stylesheet_path': fixpath('data/stylesheets/pep.css'),
56
 
                'template': fixpath('data/pep-html-template')},
57
 
        'two': {'generator': 0,
58
 
                'stylesheet_path': fixpath('data/test.css')},
 
59
                'tab_width': 8,
 
60
                'template': fixpath('data/pep-html-template'),
 
61
                'trim_footnote_reference_space': 1},
 
62
        'two': {'footnote_references': 'superscript',
 
63
                'generator': 0,
 
64
                'record_dependencies': utils.DependencyList(),
 
65
                'stylesheet': None,
 
66
                'stylesheet_path': fixpath('data/test.css'),
 
67
                'trim_footnote_reference_space': None},
59
68
        'list': {'expose_internals': ['a', 'b', 'c', 'd', 'e']},
60
69
        'list2': {'expose_internals': ['a', 'b', 'c', 'd', 'e', 'f']},
61
70
        'error': {'error_encoding': 'ascii',
62
71
                  'error_encoding_error_handler': 'strict'},
63
72
        }
64
73
 
65
 
    compare = difflib.Differ().compare
 
74
    compare = docutils_difflib.Differ().compare
66
75
    """Comparison method shared by all tests."""
67
76
 
68
77
    def setUp(self):
69
78
        self.option_parser = frontend.OptionParser(
70
 
            components=(pep_html.Writer,), read_config_files=None)
 
79
            components=(pep_html.Writer, rst.Parser), read_config_files=None)
71
80
 
72
81
    def files_settings(self, *names):
73
82
        settings = frontend.Values()
84
93
 
85
94
    def compare_output(self, result, expected):
86
95
        """`result` and `expected` should both be dicts."""
 
96
        self.assert_(result.has_key('record_dependencies'))
 
97
        if not expected.has_key('record_dependencies'):
 
98
            # Delete it if we don't want to test it.
 
99
            del result['record_dependencies']
87
100
        result = pprint.pformat(result) + '\n'
88
101
        expected = pprint.pformat(expected) + '\n'
89
102
        try: