Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_getargs.py @ 58925:eecf1bef052d 2.6
Merged revisions 78207 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line
#7930: fix stripid
........
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Tue, 16 Feb 2010 23:29:44 +0000 |
| parents | 7f13d6904e14 |
| children | 8ab5bbae5efe |
| rev | line source |
|---|---|
|
45814
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
1 """ |
|
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
2 Test the internal getargs.c implementation |
|
19821
3f73a8bf76f7
Test the failed-unicode-decoding bug in PyArg_ParseTuple().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
3 |
|
3f73a8bf76f7
Test the failed-unicode-decoding bug in PyArg_ParseTuple().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
4 PyArg_ParseTuple() is defined here. |
|
3f73a8bf76f7
Test the failed-unicode-decoding bug in PyArg_ParseTuple().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
5 |
|
3f73a8bf76f7
Test the failed-unicode-decoding bug in PyArg_ParseTuple().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
6 The test here is not intended to test all of the module, just the |
|
3f73a8bf76f7
Test the failed-unicode-decoding bug in PyArg_ParseTuple().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
7 single case that failed between 2.1 and 2.2a2. |
|
3f73a8bf76f7
Test the failed-unicode-decoding bug in PyArg_ParseTuple().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
8 """ |
|
3f73a8bf76f7
Test the failed-unicode-decoding bug in PyArg_ParseTuple().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
9 |
|
3f73a8bf76f7
Test the failed-unicode-decoding bug in PyArg_ParseTuple().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
10 # marshal.loads() uses PyArg_ParseTuple(args, "s#:loads") |
|
3f73a8bf76f7
Test the failed-unicode-decoding bug in PyArg_ParseTuple().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
11 # The s code will cause a Unicode conversion to occur. This test |
|
3f73a8bf76f7
Test the failed-unicode-decoding bug in PyArg_ParseTuple().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
12 # verify that the error is propagated properly from the C code back to |
|
3f73a8bf76f7
Test the failed-unicode-decoding bug in PyArg_ParseTuple().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
13 # Python. |
|
3f73a8bf76f7
Test the failed-unicode-decoding bug in PyArg_ParseTuple().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
14 |
|
3f73a8bf76f7
Test the failed-unicode-decoding bug in PyArg_ParseTuple().
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
15 import marshal |
|
45814
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
16 import unittest |
|
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
17 from test import test_support |
|
23485
c76e5c1c6e45
Guess what? --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents:
19953
diff
changeset
|
18 |
|
45814
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
19 class GetArgsTest(unittest.TestCase): |
|
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
20 # If the encoding succeeds using the current default encoding, |
|
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
21 # this test will fail because it does not test the right part of the |
|
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
22 # PyArg_ParseTuple() implementation. |
|
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
23 def test_with_marshal(self): |
|
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
24 if not test_support.have_unicode: |
|
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
25 return |
|
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
26 |
|
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
27 arg = unicode(r'\222', 'unicode-escape') |
|
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
28 self.assertRaises(UnicodeError, marshal.loads, arg) |
|
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
29 |
|
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
30 def test_main(): |
|
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
31 test_support.run_unittest(GetArgsTest) |
|
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
32 |
|
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
33 if __name__ == '__main__': |
|
7f13d6904e14
Convert test_strftime, test_getargs, and test_pep247 to use unittest.
Brett Cannon <bcannon@gmail.com>
parents:
24442
diff
changeset
|
34 test_main() |
