Debian Codegraph @

pypy/module/__pypy__/test/test_bytebuffer.py

raw symbols SCIP
1 class AppTest(object):
2 spaceconfig = dict(usemodules=['__pypy__'])
3
4 def test_bytebuffer(self):
5 from __pypy__ import bytebuffer
6 b = bytebuffer(12)
7 assert len(b) == 12
8 b[3] = ord(b'!')
9 b[5] = ord(b'?')
10 assert b[2:7] == b'\x00!\x00?\x00'
11 b[9:] = b'+-*'
12 assert b[-1] == ord(b'*')
13 assert b[-2] == ord(b'-')
14 assert b[-3] == ord(b'+')
15 exc = raises(ValueError, "b[3:5] = b'abc'")
16 assert str(exc.value) == "cannot modify size of memoryview object"
17
18 b = bytebuffer(10)
19 b[1:3] = b'xy'
20 assert bytes(b) == b"\x00xy" + b"\x00" * 7
21 b[4:8:2] = b'zw'
22 assert bytes(b) == b"\x00xy\x00z\x00w" + b"\x00" * 3
23
24 def test_buffer_getslice_empty(self):
25 from __pypy__ import bytebuffer
26 b = bytebuffer(10)
27 assert b[1:0] == b''
28
29 def test_bytebuffer_object(self):
30 from __pypy__ import bytebuffer
31 b = bytebuffer(10)
32 assert b.obj is None
33