MCPcopy Index your code
hub / github.com/python/cpython / checkequal

Method checkequal

Lib/test/string_tests.py:54–75  ·  view source on GitHub ↗
(self, result, obj, methodname, *args, **kwargs)

Source from the content-addressed store, hash-verified

52
53 # check that obj.method(*args) returns result
54 def checkequal(self, result, obj, methodname, *args, **kwargs):
55 result = self.fixtype(result)
56 obj = self.fixtype(obj)
57 args = self.fixtype(args)
58 kwargs = {k: self.fixtype(v) for k,v in kwargs.items()}
59 realresult = getattr(obj, methodname)(*args, **kwargs)
60 self.assertEqual(
61 result,
62 realresult
63 )
64 # if the original is returned make sure that
65 # this doesn't happen with subclasses
66 if obj is realresult:
67 try:
68 class subtype(self.__class__.type2test):
69 pass
70 except TypeError:
71 pass # Skip this if we can't subclass
72 else:
73 obj = subtype(obj)
74 realresult = getattr(obj, methodname)(*args)
75 self.assertIsNot(obj, realresult)
76
77 # check that obj.method(*args) raises exc
78 def checkraises(self, exc, obj, methodname, *args, expected_msg=None):

Callers 15

test_countMethod · 0.95
test_findMethod · 0.95
test_rfindMethod · 0.95
test_indexMethod · 0.95
test_rindexMethod · 0.95
check_patternMethod · 0.95
test_adaptive_findMethod · 0.95
test_find_with_memoryMethod · 0.95
test_lowerMethod · 0.95
test_upperMethod · 0.95
test_expandtabsMethod · 0.95

Calls 5

fixtypeMethod · 0.95
subtypeClass · 0.85
assertIsNotMethod · 0.80
itemsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected