Document the section subtitle transform in the functional tests.
[docutils.git] / test / test_command_line.py
blob9abcac22eeab86585d5fe1ab64240b5ea527b1ae
1 #! /usr/bin/env python
2 # .. coding: utf8
3 # $Id$
4 # Author: Günter Milde <milde@users.sourceforge.net>
5 # Copyright: This module has been placed in the public domain.
7 """
8 Test module for the command line.
9 """
11 import os.path
12 import unittest
13 import sys
14 import DocutilsTestSupport # must be imported before docutils
15 import docutils.core
16 import docutils.utils
18 try:
19 import locale
20 argv_encoding = locale.getpreferredencoding()
21 except:
22 argv_encoding = None
24 testoutput = """\
25 <document source="<stdin>" title="Dornröschen">
26 <decoration>
27 <footer>
28 <paragraph>
29 """
31 class CommandLineEncodingTests(unittest.TestCase):
33 # This does not work, as there is no "encoding" argument!
34 # def test_argv_encoding(self):
35 # if argv_encoding is None:
36 # # failure to load "locale" module
37 # return
38 # if sys.argv:
39 # self.assertEqual(sys.argv[0].encoding,
40 # locale.getpreferredencoding())
42 def test_argv_decoding(self):
43 if argv_encoding is None:
44 # failure to load "locale" module
45 return # nothing to test
46 cmd_str = (u'../tools/rst2pseudoxml.py --no-generator '
47 u'--no-datestamp --title=Dornröschen')
48 output = os.popen(cmd_str.encode(argv_encoding)).read()
50 self.assertEqual(output, testoutput)
53 if __name__ == '__main__':
54 unittest.main()