def test_get_and_putfield(): hdr = bytearray(_segyio.thsize()) with pytest.raises(BufferError): _segyio.getfield(".", 0) with pytest.raises(TypeError): _segyio.getfield([], 0) with pytest.raises(TypeError): _segyio.putfield({}, 0, 1) with pytest.raises(KeyError): _segyio.getfield(hdr, 0) with pytest.raises(KeyError): _segyio.putfield(hdr, 0, 1) _segyio.putfield(hdr, 1, 127) _segyio.putfield(hdr, 5, 67) _segyio.putfield(hdr, 9, 19) assert _segyio.getfield(hdr, 1) == 127 assert _segyio.getfield(hdr, 5) == 67 assert _segyio.getfield(hdr, 9) == 19
def test_get_and_putfield(self): hdr = bytearray(_segyio.thsize()) with self.assertRaises(BufferError): _segyio.getfield(".", 0) with self.assertRaises(TypeError): _segyio.getfield([], 0) with self.assertRaises(TypeError): _segyio.putfield({}, 0, 1) with self.assertRaises(IndexError): _segyio.getfield(hdr, 0) with self.assertRaises(IndexError): _segyio.putfield(hdr, 0, 1) _segyio.putfield(hdr, 1, 127) _segyio.putfield(hdr, 5, 67) _segyio.putfield(hdr, 9, 19) self.assertEqual(_segyio.getfield(hdr, 1), 127) self.assertEqual(_segyio.getfield(hdr, 5), 67) self.assertEqual(_segyio.getfield(hdr, 9), 19)
def mkempty(): return bytearray(_segyio.thsize())