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

Method test_nonstandard_str

Lib/test/test_apple.py:107–121  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

105 self.assert_writes([b"a\xc0\x80b\n"])
106
107 def test_nonstandard_str(self):
108 # String subclasses are accepted, but they should be converted
109 # to a standard str without calling any of their methods.
110 class CustomStr(str):
111 def splitlines(self, *args, **kwargs):
112 raise AssertionError()
113
114 def __len__(self):
115 raise AssertionError()
116
117 def __str__(self):
118 raise AssertionError()
119
120 self.log.write(CustomStr("custom\n"))
121 self.assert_writes([b"custom\n"])
122
123 def test_non_str(self):
124 # Non-string classes are not accepted.

Callers

nothing calls this directly

Calls 3

assert_writesMethod · 0.95
CustomStrClass · 0.70
writeMethod · 0.45

Tested by

no test coverage detected