MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_fromhex

Method test_fromhex

Lib/test/test_bytes.py:2193–2218  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2191 self.assertFalse(hasattr(b, 'y'))
2192
2193 def test_fromhex(self):
2194 b = self.type2test.fromhex('1a2B30')
2195 self.assertEqual(b, b'\x1a\x2b\x30')
2196 self.assertIs(type(b), self.type2test)
2197
2198 class B1(self.basetype):
2199 def __new__(cls, value):
2200 me = self.basetype.__new__(cls, value)
2201 me.foo = 'bar'
2202 return me
2203
2204 b = B1.fromhex('1a2B30')
2205 self.assertEqual(b, b'\x1a\x2b\x30')
2206 self.assertIs(type(b), B1)
2207 self.assertEqual(b.foo, 'bar')
2208
2209 class B2(self.basetype):
2210 def __init__(me, *args, **kwargs):
2211 if self.basetype is not bytes:
2212 self.basetype.__init__(me, *args, **kwargs)
2213 me.foo = 'bar'
2214
2215 b = B2.fromhex('1a2B30')
2216 self.assertEqual(b, b'\x1a\x2b\x30')
2217 self.assertIs(type(b), B2)
2218 self.assertEqual(b.foo, 'bar')
2219
2220
2221class ByteArraySubclass(bytearray):

Callers

nothing calls this directly

Calls 3

fromhexMethod · 0.45
assertEqualMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected