PageRenderTime 343ms CodeModel.GetById 171ms app.highlight 2ms RepoModel.GetById 149ms app.codeStats 0ms

/Lib/test/test_getargs.py

http://unladen-swallow.googlecode.com/
Python | 34 lines | 13 code | 6 blank | 15 comment | 3 complexity | cf2d629612d8f95b8011b8f37a2c6d98 MD5 | raw file
 1"""
 2Test the internal getargs.c implementation
 3
 4 PyArg_ParseTuple() is defined here.
 5
 6The test here is not intended to test all of the module, just the
 7single case that failed between 2.1 and 2.2a2.
 8"""
 9
10# marshal.loads() uses PyArg_ParseTuple(args, "s#:loads")
11# The s code will cause a Unicode conversion to occur.  This test
12# verify that the error is propagated properly from the C code back to
13# Python.
14
15import marshal
16import unittest
17from test import test_support
18
19class GetArgsTest(unittest.TestCase):
20    # If the encoding succeeds using the current default encoding,
21    # this test will fail because it does not test the right part of the
22    # PyArg_ParseTuple() implementation.
23    def test_with_marshal(self):
24        if not test_support.have_unicode:
25            return
26
27        arg = unicode(r'\222', 'unicode-escape')
28        self.assertRaises(UnicodeError, marshal.loads, arg)
29
30def test_main():
31    test_support.run_unittest(GetArgsTest)
32
33if __name__ == '__main__':
34    test_main()