blob: 4ac5aa2f7abad61c2b268cd1a3cd9a058ea670d6 [file] [log] [blame]
Brett Cannon6eeaddc2008-03-18 01:00:07 +00001"""
2Test the internal getargs.c implementation
Jeremy Hyltonf6491952001-09-10 01:57:12 +00003
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
Jeremy Hyltonf6491952001-09-10 01:57:12 +000015import marshal
Brett Cannon6eeaddc2008-03-18 01:00:07 +000016import unittest
17from test import test_support
Michael W. Hudson7b7ba542002-05-20 14:54:17 +000018
Brett Cannon6eeaddc2008-03-18 01:00:07 +000019class 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):
Brett Cannon6eeaddc2008-03-18 01:00:07 +000024 arg = unicode(r'\222', 'unicode-escape')
25 self.assertRaises(UnicodeError, marshal.loads, arg)
26
27def test_main():
28 test_support.run_unittest(GetArgsTest)
29
30if __name__ == '__main__':
31 test_main()