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
):
23 def get_record(self
, **settings
):
24 recordfile
= 'record.txt'
25 settings
.setdefault('source_path',
26 os
.path
.join('data', 'dependencies.txt'))
27 settings
.setdefault('settings_overrides', {})
28 settings
['settings_overrides'] = settings
['settings_overrides'].copy()
29 settings
['settings_overrides']['_disable_config'] = 1
30 if not settings
['settings_overrides'].has_key('record_dependencies'):
31 settings
['settings_overrides']['record_dependencies'] = \
32 docutils
.utils
.DependencyList(recordfile
)
33 docutils
.core
.publish_file(destination
=DocutilsTestSupport
.DevNull(),
35 settings
['settings_overrides']['record_dependencies'].close()
36 return open(recordfile
).read().splitlines()
38 def test_dependencies(self
):
39 self
.assertEqual(self
.get_record(),
40 [os
.path
.join('data', 'include.txt'),
41 os
.path
.join('data', 'raw.txt')])
42 self
.assertEqual(self
.get_record(writer_name
='latex'),
43 [os
.path
.join('data', 'include.txt'),
44 os
.path
.join('data', 'raw.txt'),
45 # this is a URL, not a path:
48 def test_csv_dependencies(self
):
52 self
.get_record(source_path
=os
.path
.join('data',
54 ['data/csv_data.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'] = os
.path
.join('data', 'stylesheet.txt')
64 so
['stylesheet'] = None
65 s
['writer_name'] = 'html'
66 self
.assert_(os
.path
.join('data', 'stylesheet.txt') not in
68 so
['embed_stylesheet'] = 1
69 self
.assert_(os
.path
.join('data', 'stylesheet.txt') in
71 del so
['embed_stylesheet']
72 s
['writer_name'] = 'latex'
73 self
.assert_(os
.path
.join('data', 'stylesheet.txt') in
77 if __name__
== '__main__':