0001 #!/usr/bin/env python 0002 # UserString is a wrapper around the native builtin string type. 0003 # UserString instances should behave similar to builtin string objects. 0004 0005 import unittest 0006 from test import test_support, string_tests 0007 0008 from UserString import UserString 0009 0010 class UserStringTest( 0011 string_tests.CommonTest, 0012 string_tests.MixinStrUnicodeUserStringTest, 0013 string_tests.MixinStrStringUserStringTest, 0014 string_tests.MixinStrUserStringTest 0015 ): 0016 0017 type2test = UserString 0018 0019 # Overwrite the three testing methods, because UserString 0020 # can't cope with arguments propagated to UserString 0021 # (and we don't test with subclasses) 0022 def checkequal(self, result, object, methodname, *args): 0023 result = self.fixtype(result) 0024 object = self.fixtype(object) 0025 # we don't fix the arguments, because UserString can't cope with it 0026 realresult = getattr(object, methodname)(*args) 0027 self.assertEqual( 0028 result, 0029 realresult 0030 ) 0031 0032 def checkraises(self, exc, object, methodname, *args): 0033 object = self.fixtype(object) 0034 # we don't fix the arguments, because UserString can't cope with it 0035 self.assertRaises( 0036 exc, 0037 getattr(object, methodname), 0038 *args 0039 ) 0040 0041 def checkcall(self, object, methodname, *args): 0042 object = self.fixtype(object) 0043 # we don't fix the arguments, because UserString can't cope with it 0044 getattr(object, methodname)(*args) 0045 0046 def test_main(): 0047 test_support.run_unittest(UserStringTest) 0048 0049 if __name__ == "__main__": 0050 test_main() 0051
Generated by PyXR 0.9.4