test_getargs.py 938 B

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