Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(13)

Side by Side Diff: Lib/test/test_userstring.py

Issue 8706: accept keyword arguments on all base type methods and builtins
Patch Set: Created 8 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/string_tests.py ('k') | Objects/bytearrayobject.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python3 1 #!/usr/bin/env python3
2 # UserString is a wrapper around the native builtin string type. 2 # UserString is a wrapper around the native builtin string type.
3 # UserString instances should behave similar to builtin string objects. 3 # UserString instances should behave similar to builtin string objects.
4 4
5 import string 5 import string
6 from test import support, string_tests 6 from test import support, string_tests
7 7
8 from collections import UserString 8 from collections import UserString
9 9
10 class UserStringTest( 10 class UserStringTest(
11 string_tests.CommonTest, 11 string_tests.CommonTest,
12 string_tests.MixinStrUnicodeUserStringTest, 12 string_tests.MixinStrUnicodeUserStringTest,
13 ): 13 ):
14 14
15 type2test = UserString 15 type2test = UserString
16 16
17 # Overwrite the three testing methods, because UserString 17 # Overwrite the three testing methods, because UserString
18 # can't cope with arguments propagated to UserString 18 # can't cope with arguments propagated to UserString
19 # (and we don't test with subclasses) 19 # (and we don't test with subclasses)
20 def checkequal(self, result, object, methodname, *args, **kwargs): 20 def checkequal(self, result, object, methodname, *args, **kwargs):
21 result = self.fixtype(result) 21 result = self.fixtype(result)
22 object = self.fixtype(object) 22 object = self.fixtype(object)
23 # we don't fix the arguments, because UserString can't cope with it 23 # we don't fix the arguments, because UserString can't cope with it
24 realresult = getattr(object, methodname)(*args, **kwargs) 24 realresult = getattr(object, methodname)(*args, **kwargs)
25 self.assertEqual( 25 self.assertEqual(
26 result, 26 result,
27 realresult 27 realresult
28 ) 28 )
29 29
30 def checkraises(self, exc, object, methodname, *args): 30 def checkraises(self, exc, object, methodname, *args, **kwargs):
31 object = self.fixtype(object) 31 object = self.fixtype(object)
32 # we don't fix the arguments, because UserString can't cope with it 32 # we don't fix the arguments, because UserString can't cope with it
33 self.assertRaises( 33 self.assertRaises(
34 exc, 34 exc,
35 getattr(object, methodname), 35 getattr(object, methodname),
36 *args 36 *args,
37 **kwargs
37 ) 38 )
38 39
39 def checkcall(self, object, methodname, *args): 40 def checkcall(self, object, methodname, *args):
40 object = self.fixtype(object) 41 object = self.fixtype(object)
41 # we don't fix the arguments, because UserString can't cope with it 42 # we don't fix the arguments, because UserString can't cope with it
42 getattr(object, methodname)(*args) 43 getattr(object, methodname)(*args)
43 44
44 45
45 def test_main(): 46 def test_main():
46 support.run_unittest(UserStringTest) 47 support.run_unittest(UserStringTest)
47 48
48 if __name__ == "__main__": 49 if __name__ == "__main__":
49 test_main() 50 test_main()
OLDNEW
« no previous file with comments | « Lib/test/string_tests.py ('k') | Objects/bytearrayobject.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+