annotate Lib/test/test_userstring.py @ 51749:1408feec0084 3.0

Merged revisions 69798 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r69798 | benjamin.peterson | 2009-02-19 22:02:38 -0600 (Thu, 19 Feb 2009) | 13 lines Merged revisions 69769,69776 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r69769 | georg.brandl | 2009-02-19 02:30:06 -0600 (Thu, 19 Feb 2009) | 1 line #5310, #3558: fix operator precedence table. ........ r69776 | georg.brandl | 2009-02-19 10:34:51 -0600 (Thu, 19 Feb 2009) | 2 lines #5317: update IronPython URL. ........ ................
author Benjamin Peterson <benjamin@python.org>
date Fri, 20 Feb 2009 04:05:32 +0000
parents 9c930a32cebb
children fcfe324663a6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12214
a216fe79ae00 UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
1 #!/usr/bin/env python
a216fe79ae00 UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
2 # UserString is a wrapper around the native builtin string type.
a216fe79ae00 UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
3 # UserString instances should behave similar to builtin string objects.
28009
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
4
42954
27f0289b6835 Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents: 42088
diff changeset
5 import string
47201
9c930a32cebb #2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents: 45471
diff changeset
6 from test import support, string_tests
28009
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
7
45424
a9e1fdaf413d Move UserString to collections.
Raymond Hettinger <python@rcn.com>
parents: 42954
diff changeset
8 from collections import UserString
12214
a216fe79ae00 UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
9
28009
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
10 class UserStringTest(
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
11 string_tests.CommonTest,
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
12 string_tests.MixinStrUnicodeUserStringTest,
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
13 ):
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
14
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
15 type2test = UserString
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
16
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
17 # Overwrite the three testing methods, because UserString
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
18 # can't cope with arguments propagated to UserString
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
19 # (and we don't test with subclasses)
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
20 def checkequal(self, result, object, methodname, *args):
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
21 result = self.fixtype(result)
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
22 object = self.fixtype(object)
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
23 # we don't fix the arguments, because UserString can't cope with it
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
24 realresult = getattr(object, methodname)(*args)
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
25 self.assertEqual(
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
26 result,
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
27 realresult
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
28 )
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
29
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
30 def checkraises(self, exc, object, methodname, *args):
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
31 object = self.fixtype(object)
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
32 # we don't fix the arguments, because UserString can't cope with it
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
33 self.assertRaises(
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
34 exc,
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
35 getattr(object, methodname),
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
36 *args
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
37 )
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
38
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
39 def checkcall(self, object, methodname, *args):
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
40 object = self.fixtype(object)
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
41 # we don't fix the arguments, because UserString can't cope with it
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
42 getattr(object, methodname)(*args)
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
43
34609
c60fde8b0106 Add tests for the methods added by UserString.MutableString.
Walter Dörwald <walter@livinglogic.de>
parents: 34606
diff changeset
44
28009
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
45 def test_main():
47201
9c930a32cebb #2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents: 45471
diff changeset
46 support.run_unittest(UserStringTest)
28009
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
47
12214
a216fe79ae00 UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
48 if __name__ == "__main__":
28009
fe10ece8ba68 Port all string tests to PyUnit and share as much tests
Walter Dörwald <walter@livinglogic.de>
parents: 24684
diff changeset
49 test_main()