3 # Author: Felix Wiemann
4 # Contact: Felix_Wiemann@ososo.de
7 # Copyright: This module has been placed in the public domain.
10 Test module for the --record-dependencies option.
16 import DocutilsTestSupport
# must be imported before docutils
21 class RecordDependenciesTests(unittest
.TestCase
):
24 os
.chdir(os
.path
.join(DocutilsTestSupport
.testroot
, 'data'))
26 def get_record(self
, inputfile
=None, **settings
):
28 recordfile
= 'record.txt'
29 settings
.setdefault('source_path', 'dependencies.txt')
30 settings
.setdefault('settings_overrides', {})
31 settings
['settings_overrides'] = settings
['settings_overrides'].copy()
32 settings
['settings_overrides']['_disable_config'] = 1
33 if not settings
['settings_overrides'].has_key('record_dependencies'):
34 settings
['settings_overrides']['record_dependencies'] = \
35 docutils
.utils
.DependencyList(recordfile
)
36 docutils
.core
.publish_file(destination
=DocutilsTestSupport
.DevNull(),
38 settings
['settings_overrides']['record_dependencies'].close()
39 return open(recordfile
).read().splitlines()
41 def test_dependencies(self
):
42 self
.assertEqual(self
.get_record(),
45 self
.assertEqual(self
.get_record(writer_name
='latex'),
50 def test_csv_dependencies(self
):
53 self
.assertEqual(self
.get_record(source_path
='csv_dep.txt'),
58 def test_stylesheet_dependencies(self
):
59 # Parameters to publish_file.
60 s
= {'settings_overrides': {}}
61 so
= s
['settings_overrides']
62 so
['embed_stylesheet'] = 0
63 so
['stylesheet_path'] = 'stylesheet.txt'
64 so
['stylesheet'] = None
65 s
['writer_name'] = 'html'
66 self
.assert_('stylesheet.txt' not in
68 so
['embed_stylesheet'] = 1
69 self
.assert_('stylesheet.txt' in
71 del so
['embed_stylesheet']
72 s
['writer_name'] = 'latex'
73 self
.assert_('stylesheet.txt' in
77 if __name__
== '__main__':