Skip to content

Commit

Permalink
Fix tests. Also do an image comparison test.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjdcs committed Apr 27, 2023
1 parent 3d927e4 commit b1ca2a0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 27 additions & 1 deletion colour/plotting/tm3018/tests/test_report.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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()

0 comments on commit b1ca2a0

Please sign in to comment.