Skip to content
Snippets Groups Projects
Commit 1cafa1cf authored by Mayr, Hannes's avatar Mayr, Hannes
Browse files

Add unittest for wrong font file.

parent 128c3ec2
No related tags found
1 merge request!60Enable customization of plotted IDs
Pipeline #888184 passed
...@@ -39,7 +39,7 @@ def tagplot_image(plotid_object: PlotOptions) -> PlotIDTransfer: ...@@ -39,7 +39,7 @@ def tagplot_image(plotid_object: PlotOptions) -> PlotIDTransfer:
if not isinstance(img, str): if not isinstance(img, str):
raise TypeError("Name of the image is not a string.") raise TypeError("Name of the image is not a string.")
if not os.path.isfile(img): 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 # Check if figs is a valid file is done by pillow internally
color = tuple(rgb_value * 255 for rgb_value in plotid_object.fontcolor) color = tuple(rgb_value * 255 for rgb_value in plotid_object.fontcolor)
......
...@@ -88,6 +88,13 @@ class TestTagplotImage(unittest.TestCase): ...@@ -88,6 +88,13 @@ class TestTagplotImage(unittest.TestCase):
with self.assertRaises(TypeError): with self.assertRaises(TypeError):
tagplot_image("wrong_object") 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: def tearDown(self) -> None:
os.remove(IMG1) os.remove(IMG1)
os.remove(IMG2) os.remove(IMG2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment