4 # Author: Günter Milde <milde@users.sourceforge.net>
5 # Copyright: This module has been placed in the public domain.
8 Test module for the command line.
13 import DocutilsTestSupport
# must be imported before docutils
16 # determine/guess the encoding of the standard input:
18 import locale
# module missing in Jython
19 locale_encoding
= locale
.getlocale()[1] or locale
.getdefaultlocale()[1]
21 locale_encoding
= None
23 argv_encoding
= locale_encoding
or 'ascii'
25 codecs
.lookup(argv_encoding
)
27 argv_encoding
= 'ascii'
30 class CommandLineEncodingTests(unittest
.TestCase
):
32 def test_sys_argv_decoding(self
):
33 if argv_encoding
== 'ascii': # cannot test
35 sys
.argv
.append('--source-url=test.txt') # pure ASCII argument
36 if sys
.version_info
< (3,0):
37 sys
.argv
.append(u
'--title=Dornröschen'.encode(argv_encoding
))
39 sys
.argv
.append(u
'--title=Dornröschen')
40 publisher
= docutils
.core
.Publisher()
41 publisher
.process_command_line()
42 self
.assertEqual(publisher
.settings
.source_url
, 'test.txt')
43 self
.assertEqual(publisher
.settings
.title
, u
'Dornröschen')
44 sys
.argv
.pop() # --title
45 sys
.argv
.pop() # --source-url
48 if __name__
== '__main__':