def test_open_image_bad_path(self): """Should raise a FileNotFoundError if the file doesn't exist.""" image_path = "some_image.png" xlsform_path = "" self.assertFalse(os.path.isfile(image_path)) with self.assertRaises(FileNotFoundError): Images._locate_and_open_image( image_path=image_path, xlsform_path=xlsform_path)
def test_open_image_relative_path(self): """Should return Image if the path is relative to the xlsform.""" xlsform_path = os.path.join(self.cwd, "reference_images/xlsform.xlsx") image_path = "open_image.png" observed = Images._locate_and_open_image( image_path=image_path, xlsform_path=xlsform_path) self.assertIsInstance(observed, Image.Image)
def test_open_image_absolute_path(self): """Should return Image if the path is absolute.""" image_path = os.path.join( self.cwd, "reference_images", "open_image.png") xlsform_path = "xlsform.xlsx" observed = Images._locate_and_open_image( image_path=image_path, xlsform_path=xlsform_path) self.assertIsInstance(observed, Image.Image)