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.
15
import docutils_difflib
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
24
26
warnings.filterwarnings(action='ignore',
25
27
category=frontend.ConfigDeprecationWarning)
28
return os.path.abspath(os.path.join(mydir, path))
30
mydir = os.path.dirname(fixpath.func_code.co_filename)
30
return os.path.abspath(os.path.join(*(path.split('/'))))
33
33
class ConfigFileTests(unittest.TestCase):
46
46
'python_home': 'http://www.python.org',
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',
53
54
'python_home': 'http://www.python.org',
55
'record_dependencies': utils.DependencyList(),
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')},
60
'template': fixpath('data/pep-html-template'),
61
'trim_footnote_reference_space': 1},
62
'two': {'footnote_references': 'superscript',
64
'record_dependencies': utils.DependencyList(),
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'},
65
compare = difflib.Differ().compare
74
compare = docutils_difflib.Differ().compare
66
75
"""Comparison method shared by all tests."""
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)
72
81
def files_settings(self, *names):
73
82
settings = frontend.Values()
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'