diff --git a/colour/plotting/tm3018/tests/resources/TM30_Report_Example.png b/colour/plotting/tm3018/tests/resources/TM30_Report_Example.png new file mode 100644 index 0000000000..1929e849c8 Binary files /dev/null and b/colour/plotting/tm3018/tests/resources/TM30_Report_Example.png differ diff --git a/colour/plotting/tm3018/tests/test_report.py b/colour/plotting/tm3018/tests/test_report.py index 2ce05daf9c..bc38dac758 100644 --- a/colour/plotting/tm3018/tests/test_report.py +++ b/colour/plotting/tm3018/tests/test_report.py @@ -1,16 +1,21 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.plotting.tm3018.report` module.""" +import os import unittest +from matplotlib.backends.backend_agg import FigureCanvasAgg from matplotlib.pyplot import Axes, Figure +import numpy as np from colour.colorimetry import SDS_ILLUMINANTS +from colour.io.image import read_image from colour.plotting.tm3018.report import ( plot_single_sd_colour_rendition_report_full, plot_single_sd_colour_rendition_report_intermediate, plot_single_sd_colour_rendition_report_simple, plot_single_sd_colour_rendition_report, ) +from colour.utilities.array import as_array __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" @@ -103,10 +108,31 @@ def test_plot_single_sd_colour_rendition_report(self): figure, axes = plot_single_sd_colour_rendition_report( SDS_ILLUMINANTS["FL2"] ) - self.assertIsInstance(figure, Figure) self.assertIsInstance(axes, Axes) + canvas = FigureCanvasAgg(figure) + canvas.draw() + + test_img = as_array(canvas.buffer_rgba()) / 255 + + ROOT_RESOURCES: str = os.path.join( + os.path.dirname(__file__), "resources" + ) + + ref_image_path = os.path.join( + ROOT_RESOURCES, "TM30_Report_Example.png" + ) + ref_image = read_image(ref_image_path) + + np.testing.assert_allclose( + ref_image, + test_img, + err_msg="TM30 Report Image Changed", + atol=1 / 255, + rtol=0, + ) + if __name__ == "__main__": unittest.main()