blob: 990199ed5c3d217fa131e6460e946bc06beba3a6 [file] [log] [blame]
Fred Drakea22b5762000-04-03 03:51:50 +00001#!/usr/bin/env python
Fred Drakea22b5762000-04-03 03:51:50 +00002# UserString is a wrapper around the native builtin string type.
3# UserString instances should behave similar to builtin string objects.
Walter Dörwald0fd583c2003-02-21 12:53:50 +00004
5import unittest
6from test import test_support, string_tests
7
Fred Drakea22b5762000-04-03 03:51:50 +00008from UserString import UserString
9
Walter Dörwald0fd583c2003-02-21 12:53:50 +000010class UserStringTest(
11 string_tests.CommonTest,
12 string_tests.MixinStrUnicodeUserStringTest,
13 string_tests.MixinStrStringUserStringTest,
Hye-Shik Change9ddfbb2004-08-04 07:38:35 +000014 string_tests.MixinStrUserStringTest
Walter Dörwald0fd583c2003-02-21 12:53:50 +000015 ):
16
17 type2test = UserString
18
19 # Overwrite the three testing methods, because UserString
20 # can't cope with arguments propagated to UserString
21 # (and we don't test with subclasses)
22 def checkequal(self, result, object, methodname, *args):
23 result = self.fixtype(result)
24 object = self.fixtype(object)
25 # we don't fix the arguments, because UserString can't cope with it
26 realresult = getattr(object, methodname)(*args)
27 self.assertEqual(
28 result,
29 realresult
30 )
31
32 def checkraises(self, exc, object, methodname, *args):
33 object = self.fixtype(object)
34 # we don't fix the arguments, because UserString can't cope with it
35 self.assertRaises(
36 exc,
37 getattr(object, methodname),
38 *args
39 )
40
41 def checkcall(self, object, methodname, *args):
42 object = self.fixtype(object)
43 # we don't fix the arguments, because UserString can't cope with it
44 getattr(object, methodname)(*args)
45
46def test_main():
Walter Dörwald21d3a322003-05-01 17:45:56 +000047 test_support.run_unittest(UserStringTest)
Walter Dörwald0fd583c2003-02-21 12:53:50 +000048
Fred Drakea22b5762000-04-03 03:51:50 +000049if __name__ == "__main__":
Walter Dörwald0fd583c2003-02-21 12:53:50 +000050 test_main()