mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
style: use Black everywhere (#2594)
* style: use Black everywhere * style: minor touchup from review
This commit is contained in:
@@ -46,8 +46,8 @@ def test_to_python():
|
||||
mat[3, 2] = 7.0
|
||||
assert mat[2, 3] == 4
|
||||
assert mat[3, 2] == 7
|
||||
assert struct.unpack_from('f', mat, (3 * 4 + 2) * 4) == (7, )
|
||||
assert struct.unpack_from('f', mat, (2 * 4 + 3) * 4) == (4, )
|
||||
assert struct.unpack_from("f", mat, (3 * 4 + 2) * 4) == (7,)
|
||||
assert struct.unpack_from("f", mat, (2 * 4 + 3) * 4) == (4,)
|
||||
|
||||
mat2 = np.array(mat, copy=False)
|
||||
assert mat2.shape == (5, 4)
|
||||
@@ -83,31 +83,31 @@ def test_pointer_to_member_fn():
|
||||
for cls in [m.Buffer, m.ConstBuffer, m.DerivedBuffer]:
|
||||
buf = cls()
|
||||
buf.value = 0x12345678
|
||||
value = struct.unpack('i', bytearray(buf))[0]
|
||||
value = struct.unpack("i", bytearray(buf))[0]
|
||||
assert value == 0x12345678
|
||||
|
||||
|
||||
def test_readonly_buffer():
|
||||
buf = m.BufferReadOnly(0x64)
|
||||
view = memoryview(buf)
|
||||
assert view[0] == b'd' if env.PY2 else 0x64
|
||||
assert view[0] == b"d" if env.PY2 else 0x64
|
||||
assert view.readonly
|
||||
|
||||
|
||||
def test_selective_readonly_buffer():
|
||||
buf = m.BufferReadOnlySelect()
|
||||
|
||||
memoryview(buf)[0] = b'd' if env.PY2 else 0x64
|
||||
memoryview(buf)[0] = b"d" if env.PY2 else 0x64
|
||||
assert buf.value == 0x64
|
||||
|
||||
io.BytesIO(b'A').readinto(buf)
|
||||
assert buf.value == ord(b'A')
|
||||
io.BytesIO(b"A").readinto(buf)
|
||||
assert buf.value == ord(b"A")
|
||||
|
||||
buf.readonly = True
|
||||
with pytest.raises(TypeError):
|
||||
memoryview(buf)[0] = b'\0' if env.PY2 else 0
|
||||
memoryview(buf)[0] = b"\0" if env.PY2 else 0
|
||||
with pytest.raises(TypeError):
|
||||
io.BytesIO(b'1').readinto(buf)
|
||||
io.BytesIO(b"1").readinto(buf)
|
||||
|
||||
|
||||
def test_ctypes_array_1d():
|
||||
|
||||
Reference in New Issue
Block a user