Coverage for io/tests/test_xrite.py: 100%

1"""Define the unit tests for the :mod:`colour.io.xrite` module."""

2

3 from __future__ import annotations

4

5 import os

6

7 from colour.colorimetry import SpectralDistribution

8 from colour.io import read_sds_from_xrite_file

9

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"

16

17 __all__ = [

18 "ROOT_RESOURCES",

19 "COLOURCHECKER_XRITE_1",

20 "TestReadSdsFromXRiteFile",

21]

22

23 ROOT_RESOURCES: str = os.path.join(os.path.dirname(__file__), "resources")

24

25 COLOURCHECKER_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}

63

64

65 class TestReadSdsFromXRiteFile:

66 """

67 Define :func:`colour.io.xrite.read_sds_from_xrite_file` definition unit

68 tests methods.

69 """

70

71 def test_read_sds_from_xrite_file(self) -> None:

72 """Test :func:`colour.io.xrite.read_sds_from_xrite_file` definition."""

73

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)

80

81 assert sds["X1"] == SpectralDistribution(COLOURCHECKER_XRITE_1, name="X1")