def it_can_construct_from_a_path(self, from_blob_, image_): with open(test_image_path, "rb") as f: blob = f.read() from_blob_.return_value = image_ image = Image.from_file(test_image_path) Image.from_blob.assert_called_once_with(blob, "python-icon.jpeg") assert image is image_
def get_or_add_image_part(self, image_file): """Return |ImagePart| object containing the image in `image_file`. `image_file` can be either a path to an image file or a file-like object containing an image. If an image part containing this same image already exists, that instance is returned, otherwise a new image part is created. """ image = Image.from_file(image_file) image_part = self._find_by_sha1(image.sha1) return ImagePart.new(self._package, image) if image_part is None else image_part
def it_can_construct_from_a_path(self, from_path_fixture): image_file, blob, filename, image_ = from_path_fixture image = Image.from_file(image_file) Image.from_blob.assert_called_once_with(blob, filename) assert image is image_
def it_can_construct_from_a_stream(self, from_stream_fixture): image_file, blob, image_ = from_stream_fixture image = Image.from_file(image_file) Image.from_blob.assert_called_once_with(blob, None) assert image is image_
def it_can_construct_from_a_stream(self, from_stream_fixture): image_file, blob, image_ = from_stream_fixture image = Image.from_file(image_file) Image.from_blob.assert_called_once_with(blob, None) assert image is image_
def it_can_construct_from_a_path(self, from_path_fixture): image_file, blob, filename, image_ = from_path_fixture image = Image.from_file(image_file) Image.from_blob.assert_called_once_with(blob, filename) assert image is image_