Coverage for io/tests/test_xrite.py: 100%
20 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-16 22:49 +1300
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-16 22:49 +1300
1"""Define the unit tests for the :mod:`colour.io.xrite` module."""
3from __future__ import annotations
5import os
7from colour.colorimetry import SpectralDistribution
8from colour.io import read_sds_from_xrite_file
10__author__ = "Colour Developers"
11__copyright__ = "Copyright 2013 Colour Developers"
12__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
13__maintainer__ = "Colour Developers"
14__email__ = "colour-developers@colour-science.org"
15__status__ = "Production"
17__all__ = [
18 "ROOT_RESOURCES",
19 "COLOURCHECKER_XRITE_1",
20 "TestReadSdsFromXRiteFile",
21]
23ROOT_RESOURCES: str = os.path.join(os.path.dirname(__file__), "resources")
25COLOURCHECKER_XRITE_1: dict = {
26 380.0: 0.0069,
27 390.0: 0.0069,
28 400.0: 0.0068,
29 410.0: 0.0068,
30 420.0: 0.0073,
31 430.0: 0.0075,
32 440.0: 0.0065,
33 450.0: 0.0074,
34 460.0: 0.0073,
35 470.0: 0.0073,
36 480.0: 0.0074,
37 490.0: 0.0074,
38 500.0: 0.0075,
39 510.0: 0.0075,
40 520.0: 0.0072,
41 530.0: 0.0072,
42 540.0: 0.0072,
43 550.0: 0.0072,
44 560.0: 0.0072,
45 570.0: 0.0071,
46 580.0: 0.0071,
47 590.0: 0.0071,
48 600.0: 0.0071,
49 610.0: 0.0072,
50 620.0: 0.0071,
51 630.0: 0.0071,
52 640.0: 0.0071,
53 650.0: 0.0070,
54 660.0: 0.0074,
55 670.0: 0.0068,
56 680.0: 0.0067,
57 690.0: 0.0067,
58 700.0: 0.0066,
59 710.0: 0.0066,
60 720.0: 0.0066,
61 730.0: 0.0065,
62}
65class TestReadSdsFromXRiteFile:
66 """
67 Define :func:`colour.io.xrite.read_sds_from_xrite_file` definition unit
68 tests methods.
69 """
71 def test_read_sds_from_xrite_file(self) -> None:
72 """Test :func:`colour.io.xrite.read_sds_from_xrite_file` definition."""
74 colour_checker_xrite = os.path.join(
75 ROOT_RESOURCES, "X-Rite_Digital_Colour_Checker.txt"
76 )
77 sds = read_sds_from_xrite_file(colour_checker_xrite)
78 for sd in sds.values():
79 assert isinstance(sd, SpectralDistribution)
81 assert sds["X1"] == SpectralDistribution(COLOURCHECKER_XRITE_1, name="X1")