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

Method test_p_code

Lib/test/test_struct.py:351–366  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

349 assertStructError(struct.unpack, format, b"")
350
351 def test_p_code(self):
352 # Test p ("Pascal string") code.
353 for code, input, expected, expectedback in [
354 ('0p', b'abc', b'', b''),
355 ('p', b'abc', b'\x00', b''),
356 ('1p', b'abc', b'\x00', b''),
357 ('2p', b'abc', b'\x01a', b'a'),
358 ('3p', b'abc', b'\x02ab', b'ab'),
359 ('4p', b'abc', b'\x03abc', b'abc'),
360 ('5p', b'abc', b'\x03abc\x00', b'abc'),
361 ('6p', b'abc', b'\x03abc\x00\x00', b'abc'),
362 ('1000p', b'x'*1000, b'\xff' + b'x'*999, b'x'*255)]:
363 got = struct.pack(code, input)
364 self.assertEqual(got, expected)
365 (got,) = struct.unpack(code, got)
366 self.assertEqual(got, expectedback)
367
368 @unittest.expectedFailure # TODO: RUSTPYTHON
369 def test_705836(self):

Callers

nothing calls this directly

Calls 3

packMethod · 0.45
assertEqualMethod · 0.45
unpackMethod · 0.45

Tested by

no test coverage detected