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

Method fixtype

Lib/test/string_tests.py:35–48  ·  view source on GitHub ↗
(self, obj)

Source from the content-addressed store, hash-verified

33 # as str objects. fixtype() can be used to propagate
34 # these arguments to the appropriate type
35 def fixtype(self, obj):
36 if isinstance(obj, str):
37 return self.__class__.type2test(obj)
38 elif isinstance(obj, list):
39 return [self.fixtype(x) for x in obj]
40 elif isinstance(obj, tuple):
41 return tuple([self.fixtype(x) for x in obj])
42 elif isinstance(obj, dict):
43 return dict([
44 (self.fixtype(key), self.fixtype(value))
45 for (key, value) in obj.items()
46 ])
47 else:
48 return obj
49
50 def test_fixtype(self):
51 self.assertIs(type(self.fixtype("123")), self.type2test)

Callers 15

test_fixtypeMethod · 0.95
checkequalMethod · 0.95
checkraisesMethod · 0.95
checkcallMethod · 0.95
_get_teststringsMethod · 0.95
test_addMethod · 0.95
test_mulMethod · 0.95
test_cmpMethod · 0.95
test_countMethod · 0.95
test_joinMethod · 0.45
checkequalMethod · 0.45

Calls 2

type2testMethod · 0.80
itemsMethod · 0.45

Tested by

no test coverage detected