diff options
author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2010-11-29 23:11:25 +0000 |
---|---|---|
committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2010-11-29 23:11:25 +0000 |
commit | 70c549245bfe38adaea4bf22117a6f3e297e5cc4 (patch) | |
tree | d6ed8c561e0ab4d1f149ca14dbb9ce411582350b /test/test_command_line.py | |
parent | e601bb06e4676eac5bb193eddd0e09bd850a2735 (diff) | |
download | docutils-70c549245bfe38adaea4bf22117a6f3e297e5cc4.tar.gz |
Decode command line arguments with the locales preferred encoding.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@6487 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'test/test_command_line.py')
-rw-r--r-- | test/test_command_line.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/test_command_line.py b/test/test_command_line.py new file mode 100644 index 000000000..9abcac22e --- /dev/null +++ b/test/test_command_line.py @@ -0,0 +1,54 @@ +#! /usr/bin/env python +# .. coding: utf8 +# $Id$ +# Author: Günter Milde <milde@users.sourceforge.net> +# Copyright: This module has been placed in the public domain. + +""" +Test module for the command line. +""" + +import os.path +import unittest +import sys +import DocutilsTestSupport # must be imported before docutils +import docutils.core +import docutils.utils + +try: + import locale + argv_encoding = locale.getpreferredencoding() +except: + argv_encoding = None + +testoutput = """\ +<document source="<stdin>" title="Dornröschen"> + <decoration> + <footer> + <paragraph> +""" + +class CommandLineEncodingTests(unittest.TestCase): + + # This does not work, as there is no "encoding" argument! + # def test_argv_encoding(self): + # if argv_encoding is None: + # # failure to load "locale" module + # return + # if sys.argv: + # self.assertEqual(sys.argv[0].encoding, + # locale.getpreferredencoding()) + + def test_argv_decoding(self): + if argv_encoding is None: + # failure to load "locale" module + return # nothing to test + cmd_str = (u'../tools/rst2pseudoxml.py --no-generator ' + u'--no-datestamp --title=Dornröschen') + output = os.popen(cmd_str.encode(argv_encoding)).read() + + self.assertEqual(output, testoutput) + + +if __name__ == '__main__': + unittest.main() |