def test_set_bytes(self): bytes_a = six.b('test bytes first set') bytes_b = six.b('the second set of bytes') e = DataMemoryElement(bytes_a) ntools.assert_equal(e.get_bytes(), bytes_a) e.set_bytes(bytes_b) ntools.assert_equal(e.get_bytes(), bytes_b)
def test_set_bytes(self): bytes_a = six.b('test bytes first set') bytes_b = six.b('the second set of bytes') e = DataMemoryElement(bytes_a) self.assertEqual(e.get_bytes(), bytes_a) e.set_bytes(bytes_b) self.assertEqual(e.get_bytes(), bytes_b)
def test_load_as_matrix_invalid_bytes(self): """ Test that data element with invalid data bytes fails to load. """ d = DataMemoryElement(content_type='image/png') d.set_bytes(b"not valid bytes") inst = PilImageReader() with pytest.raises(IOError, match="Failed to identify image from bytes " "provided by DataMemoryElement"): inst.load_as_matrix(d)