diff --git a/plotid/tagplot_image.py b/plotid/tagplot_image.py index 282b2b06499b50d855ef06520e1212d68dbc8e48..86a92dce2dd61bae1fd1205b7f9c2d18931d93de 100644 --- a/plotid/tagplot_image.py +++ b/plotid/tagplot_image.py @@ -39,7 +39,7 @@ def tagplot_image(plotid_object: PlotOptions) -> PlotIDTransfer: if not isinstance(img, str): raise TypeError("Name of the image is not a string.") if not os.path.isfile(img): - raise TypeError("File does not exist.") + raise TypeError(f"Image '{img}' does not exist.") # Check if figs is a valid file is done by pillow internally color = tuple(rgb_value * 255 for rgb_value in plotid_object.fontcolor) diff --git a/tests/test_tagplot_image.py b/tests/test_tagplot_image.py index 42dbf3e3593fdc69c52c02433811ea19ee7f53e4..727243fada6612c2a87a084646c199f38d10ee01 100644 --- a/tests/test_tagplot_image.py +++ b/tests/test_tagplot_image.py @@ -88,6 +88,13 @@ class TestTagplotImage(unittest.TestCase): with self.assertRaises(TypeError): tagplot_image("wrong_object") + def test_font_file_not_defined(self) -> None: + """Test if a Warning is raised if an invalid font file was specified.""" + options = PlotOptions(IMG1, ROTATION, POSITION, font="font") + options.validate_input() + with self.assertWarns(Warning): + tagplot_image(options) + def tearDown(self) -> None: os.remove(IMG1) os.remove(IMG2)