summaryrefslogtreecommitdiff
path: root/docutils/test/test_settings.py
diff options
context:
space:
mode:
authorwiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2005-08-17 13:59:12 +0000
committerwiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2005-08-17 13:59:12 +0000
commita4bc0d09f3d1f633a5780976d1f913e083c9564a (patch)
tree1777475e88463b08438f0719be97cc087554eadd /docutils/test/test_settings.py
parent60c69f8cf97125135948a3d35b7698ee80921137 (diff)
parent2818db9a234cc37008c5f2bb0e821f9b1fa92de2 (diff)
downloaddocutils-0.3.9.tar.gz
re-added docutils-0.3.9 tag one level deeper (without web/ and sandboxes/)docutils-0.3.9
git-svn-id: http://svn.code.sf.net/p/docutils/code/tags/docutils-0.3.9@3815 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/test/test_settings.py')
-rwxr-xr-xdocutils/test/test_settings.py167
1 files changed, 0 insertions, 167 deletions
diff --git a/docutils/test/test_settings.py b/docutils/test/test_settings.py
deleted file mode 100755
index 2a17c6eef..000000000
--- a/docutils/test/test_settings.py
+++ /dev/null
@@ -1,167 +0,0 @@
-#!/usr/bin/env python
-
-# Author: David Goodger
-# Contact: goodger@python.org
-# Revision: $Revision$
-# Date: $Date$
-# Copyright: This module has been placed in the public domain.
-
-"""
-Tests of runtime settings.
-"""
-
-import sys
-import os
-import docutils_difflib
-import pprint
-import warnings
-import unittest
-from types import StringType
-from docutils import frontend, utils
-from docutils.writers import html4css1, pep_html
-from docutils.parsers import rst
-
-
-warnings.filterwarnings(action='ignore',
- category=frontend.ConfigDeprecationWarning)
-
-def fixpath(path):
- return os.path.abspath(os.path.join(mydir, path))
-
-mydir = os.path.dirname(fixpath.func_code.co_filename)
-
-
-class ConfigFileTests(unittest.TestCase):
-
- config_files = {'old': fixpath('data/config_old.txt'),
- 'one': fixpath('data/config_1.txt'),
- 'two': fixpath('data/config_2.txt'),
- 'list': fixpath('data/config_list.txt'),
- 'list2': fixpath('data/config_list_2.txt'),
- 'error': fixpath('data/config_error_handler.txt')}
-
- settings = {
- 'old': {'datestamp': '%Y-%m-%d %H:%M UTC',
- 'generator': 1,
- 'no_random': 1,
- 'python_home': 'http://www.python.org',
- 'source_link': 1,
- 'stylesheet': None,
- 'stylesheet_path': fixpath('data/stylesheets/pep.css'),
- 'template': fixpath('data/pep-html-template')},
- 'one': {'datestamp': '%Y-%m-%d %H:%M UTC',
- 'generator': 1,
- 'no_random': 1,
- 'python_home': 'http://www.python.org',
- 'record_dependencies': utils.DependencyList(),
- 'source_link': 1,
- 'stylesheet': None,
- 'stylesheet_path': fixpath('data/stylesheets/pep.css'),
- 'template': fixpath('data/pep-html-template'),
- 'trim_footnote_reference_space': 1},
- 'two': {'footnote_references': 'superscript',
- 'generator': 0,
- 'record_dependencies': utils.DependencyList(),
- 'stylesheet': None,
- 'stylesheet_path': fixpath('data/test.css'),
- 'trim_footnote_reference_space': None},
- 'list': {'expose_internals': ['a', 'b', 'c', 'd', 'e']},
- 'list2': {'expose_internals': ['a', 'b', 'c', 'd', 'e', 'f']},
- 'error': {'error_encoding': 'ascii',
- 'error_encoding_error_handler': 'strict'},
- }
-
- compare = docutils_difflib.Differ().compare
- """Comparison method shared by all tests."""
-
- def setUp(self):
- self.option_parser = frontend.OptionParser(
- components=(pep_html.Writer, rst.Parser), read_config_files=None)
-
- def files_settings(self, *names):
- settings = frontend.Values()
- for name in names:
- settings.update(self.option_parser.get_config_file_settings(
- self.config_files[name]), self.option_parser)
- return settings.__dict__
-
- def expected_settings(self, *names):
- expected = {}
- for name in names:
- expected.update(self.settings[name])
- return expected
-
- def compare_output(self, result, expected):
- """`result` and `expected` should both be dicts."""
- self.assert_(result.has_key('record_dependencies'))
- if not expected.has_key('record_dependencies'):
- # Delete it if we don't want to test it.
- del result['record_dependencies']
- result = pprint.pformat(result) + '\n'
- expected = pprint.pformat(expected) + '\n'
- try:
- self.assertEquals(result, expected)
- except AssertionError:
- print >>sys.stderr, '\n%s\n' % (self,)
- print >>sys.stderr, '-: expected\n+: result'
- print >>sys.stderr, ''.join(self.compare(expected.splitlines(1),
- result.splitlines(1)))
- raise
-
- def test_nofiles(self):
- self.compare_output(self.files_settings(),
- self.expected_settings())
-
- def test_old(self):
- self.compare_output(self.files_settings('old'),
- self.expected_settings('old'))
-
- def test_one(self):
- self.compare_output(self.files_settings('one'),
- self.expected_settings('one'))
-
- def test_multiple(self):
- self.compare_output(self.files_settings('one', 'two'),
- self.expected_settings('one', 'two'))
-
- def test_old_and_new(self):
- self.compare_output(self.files_settings('old', 'two'),
- self.expected_settings('old', 'two'))
-
- def test_list(self):
- self.compare_output(self.files_settings('list'),
- self.expected_settings('list'))
-
- def test_list2(self):
- self.compare_output(self.files_settings('list', 'list2'),
- self.expected_settings('list2'))
-
- def test_error_handler(self):
- self.compare_output(self.files_settings('error'),
- self.expected_settings('error'))
-
-
-class ConfigEnvVarFileTests(ConfigFileTests):
-
- """
- Repeats the tests of `ConfigFileTests` using the ``DOCUTILSCONFIG``
- environment variable and the standard Docutils config file mechanism.
- """
-
- def setUp(self):
- ConfigFileTests.setUp(self)
- self.orig_environ = os.environ
- os.environ = os.environ.copy()
-
- def files_settings(self, *names):
- files = [self.config_files[name] for name in names]
- os.environ['DOCUTILSCONFIG'] = os.pathsep.join(files)
- settings = self.option_parser.get_standard_config_settings()
- return settings.__dict__
-
- def tearDown(self):
- os.environ = self.orig_environ
-
-
-if __name__ == '__main__':
- unittest.main()