diff --git a/colour/adaptation/tests/test__init__.py b/colour/adaptation/tests/test__init__.py index c764ebb6a..8a4a07f9c 100644 --- a/colour/adaptation/tests/test__init__.py +++ b/colour/adaptation/tests/test__init__.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.adaptation` module.""" -import unittest import numpy as np @@ -21,7 +20,7 @@ ] -class TestChromaticAdaptation(unittest.TestCase): +class TestChromaticAdaptation: """ Define :func:`colour.adaptation.chromatic_adaptation` definition unit tests methods. @@ -122,7 +121,3 @@ def test_domain_range_scale_chromatic_adaptation(self): value * factor, atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/adaptation/tests/test_cie1994.py b/colour/adaptation/tests/test_cie1994.py index 483d0484b..fe57bb696 100644 --- a/colour/adaptation/tests/test_cie1994.py +++ b/colour/adaptation/tests/test_cie1994.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.adaptation.cie1994` module.""" -import unittest from itertools import product import numpy as np @@ -22,7 +21,7 @@ ] -class TestChromaticAdaptationCIE1994(unittest.TestCase): +class TestChromaticAdaptationCIE1994: """ Define :func:`colour.adaptation.cie1994.chromatic_adaptation_CIE1994` definition unit tests methods. @@ -161,7 +160,3 @@ def test_nan_chromatic_adaptation_CIE1994(self): cases[..., 0], cases[..., 0], ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/adaptation/tests/test_cmccat2000.py b/colour/adaptation/tests/test_cmccat2000.py index 52f179551..2cd52f6d4 100644 --- a/colour/adaptation/tests/test_cmccat2000.py +++ b/colour/adaptation/tests/test_cmccat2000.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.adaptation.cmccat2000.""" -import unittest from itertools import product import numpy as np @@ -26,7 +25,7 @@ ] -class TestChromaticAdaptationForwardCMCCAT2000(unittest.TestCase): +class TestChromaticAdaptationForwardCMCCAT2000: """ Define :func:`colour.adaptation.cmccat2000.\ chromatic_adaptation_forward_CMCCAT2000` definition unit tests methods. @@ -161,7 +160,7 @@ def test_nan_chromatic_adaptation_forward_CMCCAT2000(self): ) -class TestChromaticAdaptationInverseCMCCAT2000(unittest.TestCase): +class TestChromaticAdaptationInverseCMCCAT2000: """ Define :func:`colour.adaptation.cmccat2000.\ chromatic_adaptation_inverse_CMCCAT2000` definition unit tests methods. @@ -294,7 +293,3 @@ def test_nan_chromatic_adaptation_inverse_CMCCAT2000(self): chromatic_adaptation_inverse_CMCCAT2000( cases, cases, cases, cases[..., 0], cases[..., 0] ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/adaptation/tests/test_fairchild1990.py b/colour/adaptation/tests/test_fairchild1990.py index 17a8cd796..0d08e009a 100644 --- a/colour/adaptation/tests/test_fairchild1990.py +++ b/colour/adaptation/tests/test_fairchild1990.py @@ -2,7 +2,6 @@ """Define the unit tests for the :mod:`colour.adaptation.fairchild1990` module.""" import contextlib -import unittest from itertools import product import numpy as np @@ -24,7 +23,7 @@ ] -class TestChromaticAdaptationFairchild1990(unittest.TestCase): +class TestChromaticAdaptationFairchild1990: """ Define :func:`colour.adaptation.fairchild1990.\ chromatic_adaptation_Fairchild1990` definition unit tests methods. @@ -148,7 +147,3 @@ def test_nan_chromatic_adaptation_Fairchild1990(self): Y_n = case[0] with contextlib.suppress(LinAlgError): chromatic_adaptation_Fairchild1990(XYZ_1, XYZ_n, XYZ_r, Y_n) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/adaptation/tests/test_vonkries.py b/colour/adaptation/tests/test_vonkries.py index 79b5c9567..19a5803a2 100644 --- a/colour/adaptation/tests/test_vonkries.py +++ b/colour/adaptation/tests/test_vonkries.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.adaptation.vonkries` module.""" -import unittest from itertools import product import numpy as np @@ -26,7 +25,7 @@ ] -class TestMatrixChromaticAdaptationVonKries(unittest.TestCase): +class TestMatrixChromaticAdaptationVonKries: """ Define :func:`colour.adaptation.vonkries.\ matrix_chromatic_adaptation_VonKries` definition unit tests methods. @@ -192,7 +191,7 @@ def test_nan_matrix_chromatic_adaptation_VonKries(self): matrix_chromatic_adaptation_VonKries(cases, cases) -class TestChromaticAdaptationVonKries(unittest.TestCase): +class TestChromaticAdaptationVonKries: """ Define :func:`colour.adaptation.vonkries.chromatic_adaptation_VonKries` definition unit tests methods. @@ -330,7 +329,3 @@ def test_nan_chromatic_adaptation_VonKries(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) chromatic_adaptation_VonKries(cases, cases, cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/adaptation/tests/test_zhai2018.py b/colour/adaptation/tests/test_zhai2018.py index 3260eb0bc..2351552ff 100644 --- a/colour/adaptation/tests/test_zhai2018.py +++ b/colour/adaptation/tests/test_zhai2018.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.adaptation.zhai2018` module.""" -import unittest from itertools import product import numpy as np @@ -22,7 +21,7 @@ ] -class TestChromaticAdaptationZhai2018(unittest.TestCase): +class TestChromaticAdaptationZhai2018: """ Define :func:`colour.adaptation.zhai2018.chromatic_adaptation_Zhai2018` definition unit tests methods. @@ -175,7 +174,3 @@ def test_nan_chromatic_adaptation_Zhai2018(self): chromatic_adaptation_Zhai2018( cases, cases, cases, cases[0, 0], cases[0, 0], cases ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/algebra/coordinates/tests/test_transformations.py b/colour/algebra/coordinates/tests/test_transformations.py index 8f5c5b7d1..6595ff4ae 100644 --- a/colour/algebra/coordinates/tests/test_transformations.py +++ b/colour/algebra/coordinates/tests/test_transformations.py @@ -3,7 +3,6 @@ :mod:`colour.algebra.coordinates.transformations` module. """ -import unittest from itertools import product import numpy as np @@ -36,7 +35,7 @@ ] -class TestCartesianToSpherical(unittest.TestCase): +class TestCartesianToSpherical: """ Define :func:`colour.algebra.coordinates.transformations.\ cartesian_to_spherical` definition unit tests methods. @@ -99,7 +98,7 @@ def test_nan_cartesian_to_spherical(self): cartesian_to_spherical(cases) -class TestSphericalToCartesian(unittest.TestCase): +class TestSphericalToCartesian: """ Define :func:`colour.algebra.coordinates.transformations.\ spherical_to_cartesian` definition unit tests methods. @@ -162,7 +161,7 @@ def test_nan_spherical_to_cartesian(self): spherical_to_cartesian(cases) -class TestCartesianToPolar(unittest.TestCase): +class TestCartesianToPolar: """ Define :func:`colour.algebra.coordinates.transformations.\ cartesian_to_polar` definition unit tests methods. @@ -225,7 +224,7 @@ def test_nan_cartesian_to_polar(self): cartesian_to_polar(cases) -class TestPolarToCartesian(unittest.TestCase): +class TestPolarToCartesian: """ Define :func:`colour.algebra.coordinates.transformations.\ polar_to_cartesian` definition unit tests methods. @@ -288,7 +287,7 @@ def test_nan_polar_to_cartesian(self): polar_to_cartesian(cases) -class TestCartesianToCylindrical(unittest.TestCase): +class TestCartesianToCylindrical: """ Define :func:`colour.algebra.coordinates.transformations.\ cartesian_to_cylindrical` definition unit tests methods. @@ -351,7 +350,7 @@ def test_nan_cartesian_to_cylindrical(self): cartesian_to_cylindrical(cases) -class TestCylindricalToCartesian(unittest.TestCase): +class TestCylindricalToCartesian: """ Define :func:`colour.algebra.coordinates.transformations.\ cylindrical_to_cartesian` definition unit tests methods. @@ -412,7 +411,3 @@ def test_nan_cylindrical_to_cartesian(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) cylindrical_to_cartesian(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/algebra/tests/test_common.py b/colour/algebra/tests/test_common.py index 92b0e9e1a..489952335 100644 --- a/colour/algebra/tests/test_common.py +++ b/colour/algebra/tests/test_common.py @@ -1,10 +1,10 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.algebra.common` module.""" -import unittest from itertools import product import numpy as np +import pytest from colour.algebra import ( eigen_decomposition, @@ -60,7 +60,7 @@ ] -class TestGetSdivMode(unittest.TestCase): +class TestGetSdivMode: """ Define :func:`colour.algebra.common.get_sdiv_mode` definition unit tests methods. @@ -70,31 +70,31 @@ def test_get_sdiv_mode(self): """Test :func:`colour.algebra.common.get_sdiv_mode` definition.""" with sdiv_mode("Numpy"): - self.assertEqual(get_sdiv_mode(), "numpy") + assert get_sdiv_mode() == "numpy" with sdiv_mode("Ignore"): - self.assertEqual(get_sdiv_mode(), "ignore") + assert get_sdiv_mode() == "ignore" with sdiv_mode("Warning"): - self.assertEqual(get_sdiv_mode(), "warning") + assert get_sdiv_mode() == "warning" with sdiv_mode("Raise"): - self.assertEqual(get_sdiv_mode(), "raise") + assert get_sdiv_mode() == "raise" with sdiv_mode("Ignore Zero Conversion"): - self.assertEqual(get_sdiv_mode(), "ignore zero conversion") + assert get_sdiv_mode() == "ignore zero conversion" with sdiv_mode("Warning Zero Conversion"): - self.assertEqual(get_sdiv_mode(), "warning zero conversion") + assert get_sdiv_mode() == "warning zero conversion" with sdiv_mode("Ignore Limit Conversion"): - self.assertEqual(get_sdiv_mode(), "ignore limit conversion") + assert get_sdiv_mode() == "ignore limit conversion" with sdiv_mode("Warning Limit Conversion"): - self.assertEqual(get_sdiv_mode(), "warning limit conversion") + assert get_sdiv_mode() == "warning limit conversion" -class TestSetSdivMode(unittest.TestCase): +class TestSetSdivMode: """ Define :func:`colour.algebra.common.set_sdiv_mode` definition unit tests methods. @@ -105,31 +105,31 @@ def test_set_sdiv_mode(self): with sdiv_mode(get_sdiv_mode()): set_sdiv_mode("Numpy") - self.assertEqual(get_sdiv_mode(), "numpy") + assert get_sdiv_mode() == "numpy" set_sdiv_mode("Ignore") - self.assertEqual(get_sdiv_mode(), "ignore") + assert get_sdiv_mode() == "ignore" set_sdiv_mode("Warning") - self.assertEqual(get_sdiv_mode(), "warning") + assert get_sdiv_mode() == "warning" set_sdiv_mode("Raise") - self.assertEqual(get_sdiv_mode(), "raise") + assert get_sdiv_mode() == "raise" set_sdiv_mode("Ignore Zero Conversion") - self.assertEqual(get_sdiv_mode(), "ignore zero conversion") + assert get_sdiv_mode() == "ignore zero conversion" set_sdiv_mode("Warning Zero Conversion") - self.assertEqual(get_sdiv_mode(), "warning zero conversion") + assert get_sdiv_mode() == "warning zero conversion" set_sdiv_mode("Ignore Limit Conversion") - self.assertEqual(get_sdiv_mode(), "ignore limit conversion") + assert get_sdiv_mode() == "ignore limit conversion" set_sdiv_mode("Warning Limit Conversion") - self.assertEqual(get_sdiv_mode(), "warning limit conversion") + assert get_sdiv_mode() == "warning limit conversion" -class TestSdivMode(unittest.TestCase): +class TestSdivMode: """ Define :func:`colour.algebra.common.sdiv_mode` definition unit tests methods. @@ -139,16 +139,16 @@ def test_sdiv_mode(self): """Test :func:`colour.algebra.common.sdiv_mode` definition.""" with sdiv_mode("Raise"): - self.assertEqual(get_sdiv_mode(), "raise") + assert get_sdiv_mode() == "raise" with sdiv_mode("Ignore Zero Conversion"): - self.assertEqual(get_sdiv_mode(), "ignore zero conversion") + assert get_sdiv_mode() == "ignore zero conversion" @sdiv_mode("Raise") def fn_a(): """:func:`sdiv_mode` unit tests :func:`fn_a` definition.""" - self.assertEqual(get_sdiv_mode(), "raise") + assert get_sdiv_mode() == "raise" fn_a() @@ -156,12 +156,12 @@ def fn_a(): def fn_b(): """:func:`sdiv_mode` unit tests :func:`fn_b` definition.""" - self.assertEqual(get_sdiv_mode(), "ignore zero conversion") + assert get_sdiv_mode() == "ignore zero conversion" fn_b() -class TestSdiv(unittest.TestCase): +class TestSdiv: """ Define :func:`colour.algebra.common.sdiv` definition unit tests methods. @@ -174,34 +174,34 @@ def test_sdiv(self): b = np.array([2, 1, 0]) with sdiv_mode("Numpy"): - self.assertWarns(RuntimeWarning, sdiv, a, b) + pytest.warns(RuntimeWarning, sdiv, a, b) with sdiv_mode("Ignore"): np.testing.assert_equal(sdiv(a, b), np.array([0, 1, np.inf])) with sdiv_mode("Warning"): - self.assertWarns(RuntimeWarning, sdiv, a, b) + pytest.warns(RuntimeWarning, sdiv, a, b) np.testing.assert_equal(sdiv(a, b), np.array([0, 1, np.inf])) with sdiv_mode("Raise"): - self.assertRaises(FloatingPointError, sdiv, a, b) + pytest.raises(FloatingPointError, sdiv, a, b) with sdiv_mode("Ignore Zero Conversion"): np.testing.assert_equal(sdiv(a, b), np.array([0, 1, 0])) with sdiv_mode("Warning Zero Conversion"): - self.assertWarns(RuntimeWarning, sdiv, a, b) + pytest.warns(RuntimeWarning, sdiv, a, b) np.testing.assert_equal(sdiv(a, b), np.array([0, 1, 0])) with sdiv_mode("Ignore Limit Conversion"): np.testing.assert_equal(sdiv(a, b), np.nan_to_num(np.array([0, 1, np.inf]))) with sdiv_mode("Warning Limit Conversion"): - self.assertWarns(RuntimeWarning, sdiv, a, b) + pytest.warns(RuntimeWarning, sdiv, a, b) np.testing.assert_equal(sdiv(a, b), np.nan_to_num(np.array([0, 1, np.inf]))) -class TestIsSpowEnabled(unittest.TestCase): +class TestIsSpowEnabled: """ Define :func:`colour.algebra.common.is_spow_enabled` definition unit tests methods. @@ -211,13 +211,13 @@ def test_is_spow_enabled(self): """Test :func:`colour.algebra.common.is_spow_enabled` definition.""" with spow_enable(True): - self.assertTrue(is_spow_enabled()) + assert is_spow_enabled() with spow_enable(False): - self.assertFalse(is_spow_enabled()) + assert not is_spow_enabled() -class TestSetSpowEnabled(unittest.TestCase): +class TestSetSpowEnabled: """ Define :func:`colour.algebra.common.set_spow_enable` definition unit tests methods. @@ -228,14 +228,14 @@ def test_set_spow_enable(self): with spow_enable(is_spow_enabled()): set_spow_enable(True) - self.assertTrue(is_spow_enabled()) + assert is_spow_enabled() with spow_enable(is_spow_enabled()): set_spow_enable(False) - self.assertFalse(is_spow_enabled()) + assert not is_spow_enabled() -class TestSpowEnable(unittest.TestCase): +class TestSpowEnable: """ Define :func:`colour.algebra.common.spow_enable` definition unit tests methods. @@ -245,16 +245,16 @@ def test_spow_enable(self): """Test :func:`colour.algebra.common.spow_enable` definition.""" with spow_enable(True): - self.assertTrue(is_spow_enabled()) + assert is_spow_enabled() with spow_enable(False): - self.assertFalse(is_spow_enabled()) + assert not is_spow_enabled() @spow_enable(True) def fn_a(): """:func:`spow_enable` unit tests :func:`fn_a` definition.""" - self.assertTrue(is_spow_enabled()) + assert is_spow_enabled() fn_a() @@ -262,12 +262,12 @@ def fn_a(): def fn_b(): """:func:`spow_enable` unit tests :func:`fn_b` definition.""" - self.assertFalse(is_spow_enabled()) + assert not is_spow_enabled() fn_b() -class TestSpow(unittest.TestCase): +class TestSpow: """ Define :func:`colour.algebra.common.spow` definition unit tests methods. @@ -276,9 +276,9 @@ class TestSpow(unittest.TestCase): def test_spow(self): """Test :func:`colour.algebra.common.spow` definition.""" - self.assertEqual(spow(2, 2), 4.0) + assert spow(2, 2) == 4.0 - self.assertEqual(spow(-2, 2), -4.0) + assert spow(-2, 2) == -4.0 np.testing.assert_allclose( spow([2, -2, -2, 0], [2, 2, 0.15, 0]), @@ -295,7 +295,7 @@ def test_spow(self): np.testing.assert_equal(spow(-2, 0.15), np.nan) -class TestNormaliseVector(unittest.TestCase): +class TestNormaliseVector: """ Define :func:`colour.algebra.common.normalise_vector` definition unit tests methods. @@ -323,7 +323,7 @@ def test_normalise_vector(self): ) -class TestNormaliseMaximum(unittest.TestCase): +class TestNormaliseMaximum: """ Define :func:`colour.algebra.common.normalise_maximum` definition unit tests methods. @@ -402,7 +402,7 @@ def test_normalise_maximum(self): ) -class TestVectorDot(unittest.TestCase): +class TestVectorDot: """ Define :func:`colour.algebra.common.vector_dot` definition unit tests methods. @@ -439,7 +439,7 @@ def test_vector_dot(self): ) -class TestMatrixDot(unittest.TestCase): +class TestMatrixDot: """ Define :func:`colour.algebra.common.matrix_dot` definition unit tests methods. @@ -499,7 +499,7 @@ def test_matrix_dot(self): ) -class TestEuclideanDistance(unittest.TestCase): +class TestEuclideanDistance: """ Define :func:`colour.algebra.common.euclidean_distance` definition unit tests methods. @@ -571,7 +571,7 @@ def test_nan_euclidean_distance(self): euclidean_distance(cases, cases) -class TestManhattanDistance(unittest.TestCase): +class TestManhattanDistance: """ Define :func:`colour.algebra.common.manhattan_distance` definition unit tests methods. @@ -643,7 +643,7 @@ def test_nan_manhattan_distance(self): manhattan_distance(cases, cases) -class TestLinearConversion(unittest.TestCase): +class TestLinearConversion: """ Define :func:`colour.algebra.common.linear_conversion` definition unit tests methods. @@ -674,7 +674,7 @@ def test_linear_conversion(self): ) -class TestLinstepFunction(unittest.TestCase): +class TestLinstepFunction: """ Define :func:`colour.algebra.common.linstep_function` definition unit tests methods. @@ -731,7 +731,7 @@ def test_linstep_function(self): ) -class TestSmoothstepFunction(unittest.TestCase): +class TestSmoothstepFunction: """ Define :func:`colour.algebra.common.smoothstep_function` definition unit tests methods. @@ -740,9 +740,9 @@ class TestSmoothstepFunction(unittest.TestCase): def test_smoothstep_function(self): """Test :func:`colour.algebra.common.smoothstep_function` definition.""" - self.assertEqual(smoothstep_function(0.5), 0.5) - self.assertEqual(smoothstep_function(0.25), 0.15625) - self.assertEqual(smoothstep_function(0.75), 0.84375) + assert smoothstep_function(0.5) == 0.5 + assert smoothstep_function(0.25) == 0.15625 + assert smoothstep_function(0.75) == 0.84375 x = np.linspace(-2, 2, 5) np.testing.assert_allclose( @@ -757,7 +757,7 @@ def test_smoothstep_function(self): ) -class TestIsIdentity(unittest.TestCase): +class TestIsIdentity: """ Define :func:`colour.algebra.common.is_identity` definition unit tests methods. @@ -766,20 +766,18 @@ class TestIsIdentity(unittest.TestCase): def test_is_identity(self): """Test :func:`colour.algebra.common.is_identity` definition.""" - self.assertTrue( - is_identity(np.reshape(np.array([1, 0, 0, 0, 1, 0, 0, 0, 1]), (3, 3))) - ) + assert is_identity(np.reshape(np.array([1, 0, 0, 0, 1, 0, 0, 0, 1]), (3, 3))) - self.assertFalse( - is_identity(np.reshape(np.array([1, 2, 0, 0, 1, 0, 0, 0, 1]), (3, 3))) + assert not is_identity( + np.reshape(np.array([1, 2, 0, 0, 1, 0, 0, 0, 1]), (3, 3)) ) - self.assertTrue(is_identity(np.reshape(np.array([1, 0, 0, 1]), (2, 2)))) + assert is_identity(np.reshape(np.array([1, 0, 0, 1]), (2, 2))) - self.assertFalse(is_identity(np.reshape(np.array([1, 2, 0, 1]), (2, 2)))) + assert not is_identity(np.reshape(np.array([1, 2, 0, 1]), (2, 2))) -class TestEigenDecomposition(unittest.TestCase): +class TestEigenDecomposition: """ Define :func:`colour.algebra.common.eigen_decomposition` definition unit tests methods. @@ -817,7 +815,3 @@ def test_is_identity(self): np.testing.assert_equal( v, np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]) ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/algebra/tests/test_extrapolation.py b/colour/algebra/tests/test_extrapolation.py index d373005b2..8faf45354 100644 --- a/colour/algebra/tests/test_extrapolation.py +++ b/colour/algebra/tests/test_extrapolation.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.algebra.extrapolation` module.""" -import unittest from itertools import product import numpy as np @@ -27,7 +26,7 @@ ] -class TestExtrapolator(unittest.TestCase): +class TestExtrapolator: """ Define :class:`colour.algebra.extrapolation.Extrapolator` class unit tests methods. @@ -39,7 +38,7 @@ def test_required_attributes(self): required_attributes = ("interpolator",) for attribute in required_attributes: - self.assertIn(attribute, dir(Extrapolator)) + assert attribute in dir(Extrapolator) def test_required_methods(self): """Test the presence of required methods.""" @@ -47,7 +46,7 @@ def test_required_methods(self): required_methods = ("__init__",) for method in required_methods: # pragma: no cover - self.assertIn(method, dir(Extrapolator)) + assert method in dir(Extrapolator) def test_interpolator(self): """ @@ -58,7 +57,7 @@ def test_interpolator(self): extrapolator = Extrapolator( LinearInterpolator(np.array([5, 6, 7]), np.array([5, 6, 7])) ) - self.assertIsInstance(extrapolator.interpolator, LinearInterpolator) + assert isinstance(extrapolator.interpolator, LinearInterpolator) def test_method(self): """ @@ -69,13 +68,13 @@ def test_method(self): extrapolator = Extrapolator( LinearInterpolator(np.array([5, 6, 7]), np.array([5, 6, 7])) ) - self.assertEqual(extrapolator.method, "linear") + assert extrapolator.method == "linear" extrapolator = Extrapolator( LinearInterpolator(np.array([5, 6, 7]), np.array([5, 6, 7])), method="Constant", ) - self.assertEqual(extrapolator.method, "constant") + assert extrapolator.method == "constant" def test_left(self): """ @@ -87,7 +86,7 @@ def test_left(self): LinearInterpolator(np.array([5, 6, 7]), np.array([5, 6, 7])), left=0, ) - self.assertEqual(extrapolator.left, 0) + assert extrapolator.left == 0 def test_right(self): """ @@ -99,7 +98,7 @@ def test_right(self): LinearInterpolator(np.array([5, 6, 7]), np.array([5, 6, 7])), right=0, ) - self.assertEqual(extrapolator.right, 0) + assert extrapolator.right == 0 def test__call__(self): """ @@ -111,14 +110,14 @@ def test__call__(self): LinearInterpolator(np.array([5, 6, 7]), np.array([5, 6, 7])) ) np.testing.assert_array_equal(extrapolator((4, 8)), (4, 8)) - self.assertEqual(extrapolator(4), 4) + assert extrapolator(4) == 4 extrapolator = Extrapolator( LinearInterpolator(np.array([3, 4, 5]), np.array([1, 2, 3])), method="Constant", ) np.testing.assert_array_equal(extrapolator((0.1, 0.2, 8, 9)), (1, 1, 3, 3)) - self.assertEqual(extrapolator(0.1), 1.0) + assert extrapolator(0.1) == 1.0 extrapolator = Extrapolator( LinearInterpolator(np.array([3, 4, 5]), np.array([1, 2, 3])), @@ -126,7 +125,7 @@ def test__call__(self): left=0, ) np.testing.assert_array_equal(extrapolator((0.1, 0.2, 8, 9)), (0, 0, 3, 3)) - self.assertEqual(extrapolator(0.1), 0) + assert extrapolator(0.1) == 0 extrapolator = Extrapolator( LinearInterpolator(np.array([3, 4, 5]), np.array([1, 2, 3])), @@ -134,7 +133,7 @@ def test__call__(self): right=0, ) np.testing.assert_array_equal(extrapolator((0.1, 0.2, 8, 9)), (1, 1, 0, 0)) - self.assertEqual(extrapolator(9), 0) + assert extrapolator(9) == 0 extrapolator = Extrapolator( CubicSplineInterpolator(np.array([3, 4, 5, 6]), np.array([1, 2, 3, 4])) @@ -144,7 +143,7 @@ def test__call__(self): (-1.9, -1.8, 6.0, 7.0), atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual(extrapolator(9), 7) + assert extrapolator(9) == 7 extrapolator = Extrapolator( PchipInterpolator(np.array([3, 4, 5]), np.array([1, 2, 3])) @@ -154,7 +153,7 @@ def test__call__(self): (-1.9, -1.8, 6.0, 7.0), atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual(extrapolator(9), 7.0) + assert extrapolator(9) == 7.0 @ignore_numpy_errors def test_nan__call__(self): @@ -168,7 +167,3 @@ def test_nan__call__(self): for case in cases: extrapolator = Extrapolator(LinearInterpolator(case, case)) extrapolator(case[0]) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/algebra/tests/test_interpolation.py b/colour/algebra/tests/test_interpolation.py index ae91172d1..479a69b66 100644 --- a/colour/algebra/tests/test_interpolation.py +++ b/colour/algebra/tests/test_interpolation.py @@ -11,10 +11,10 @@ from __future__ import annotations import os -import unittest from itertools import product import numpy as np +import pytest from colour.algebra import ( CubicSplineInterpolator, @@ -500,7 +500,7 @@ ).table -class TestKernelNearestNeighbour(unittest.TestCase): +class TestKernelNearestNeighbour: """ Define :func:`colour.algebra.interpolation.kernel_nearest_neighbour` definition unit tests methods. @@ -547,7 +547,7 @@ def test_kernel_nearest(self): ) -class TestKernelLinear(unittest.TestCase): +class TestKernelLinear: """ Define :func:`colour.algebra.interpolation.kernel_linear` definition unit tests methods. @@ -591,7 +591,7 @@ def test_kernel_linear(self): ) -class TestKernelSinc(unittest.TestCase): +class TestKernelSinc: """ Define :func:`colour.algebra.interpolation.kernel_sinc` definition unit tests methods. @@ -669,7 +669,7 @@ def test_kernel_sinc(self): ) -class TestKernelLanczos(unittest.TestCase): +class TestKernelLanczos: """ Define :func:`colour.algebra.interpolation.kernel_lanczos` definition unit tests methods. @@ -747,7 +747,7 @@ def test_kernel_lanczos(self): ) -class TestKernelCardinalSpline(unittest.TestCase): +class TestKernelCardinalSpline: """ Define :func:`colour.algebra.interpolation.kernel_cardinal_spline` definition unit tests methods. @@ -828,7 +828,7 @@ def test_kernel_cardinal_spline(self): ) -class TestKernelInterpolator(unittest.TestCase): +class TestKernelInterpolator: """ Define :class:`colour.algebra.interpolation.KernelInterpolator` class unit tests methods. @@ -847,7 +847,7 @@ def test_required_attributes(self): ) for attribute in required_attributes: - self.assertIn(attribute, dir(KernelInterpolator)) + assert attribute in dir(KernelInterpolator) def test_required_methods(self): """Test the presence of required methods.""" @@ -855,7 +855,7 @@ def test_required_methods(self): required_methods = ("__init__", "__call__") for method in required_methods: # pragma: no cover - self.assertIn(method, dir(KernelInterpolator)) + assert method in dir(KernelInterpolator) def test_x(self): """ @@ -888,7 +888,7 @@ def test_window(self): x = y = np.linspace(0, 1, 10) kernel_interpolator = KernelInterpolator(x, y, window=3) - self.assertEqual(kernel_interpolator.window, 3) + assert kernel_interpolator.window == 3 def test_kernel(self): """ @@ -899,7 +899,7 @@ def test_kernel(self): x = y = np.linspace(0, 1, 10) kernel_interpolator = KernelInterpolator(x, y, kernel=kernel_linear) - self.assertIs(kernel_interpolator.kernel, kernel_linear) + assert kernel_interpolator.kernel is kernel_linear def test_kernel_kwargs(self): """ @@ -911,7 +911,7 @@ def test_kernel_kwargs(self): kernel_kwargs = {"a": 1} kernel_interpolator = KernelInterpolator(x, y, kernel_kwargs=kernel_kwargs) - self.assertDictEqual(kernel_interpolator.kernel_kwargs, kernel_kwargs) + assert kernel_interpolator.kernel_kwargs == kernel_kwargs def test_padding_kwargs(self): """ @@ -923,7 +923,7 @@ def test_padding_kwargs(self): padding_kwargs = {"pad_width": (3, 3), "mode": "mean"} kernel_interpolator = KernelInterpolator(x, y, padding_kwargs=padding_kwargs) - self.assertDictEqual(kernel_interpolator.padding_kwargs, padding_kwargs) + assert kernel_interpolator.padding_kwargs == padding_kwargs def test_raise_exception___init__(self): """ @@ -931,7 +931,7 @@ def test_raise_exception___init__(self): method raised exception. """ - self.assertRaises( + pytest.raises( ValueError, KernelInterpolator, np.linspace(0, 1, 10), @@ -1152,9 +1152,9 @@ def test_raise_exception___call__(self): x = y = np.linspace(0, 1, 10) kernel_interpolator = KernelInterpolator(x, y) - self.assertRaises(ValueError, kernel_interpolator, -1) + pytest.raises(ValueError, kernel_interpolator, -1) - self.assertRaises(ValueError, kernel_interpolator, 11) + pytest.raises(ValueError, kernel_interpolator, 11) @ignore_numpy_errors def test_nan__call__(self): @@ -1169,7 +1169,7 @@ def test_nan__call__(self): # independent variable. -class TestNearestNeighbourInterpolator(unittest.TestCase): +class TestNearestNeighbourInterpolator: """ Define :class:`colour.algebra.interpolation.NearestNeighbourInterpolator` class unit tests methods. @@ -1181,7 +1181,7 @@ def test_required_attributes(self): required_attributes = () for attribute in required_attributes: # pragma: no cover - self.assertIn(attribute, dir(NearestNeighbourInterpolator)) + assert attribute in dir(NearestNeighbourInterpolator) def test_required_methods(self): """Test the presence of required methods.""" @@ -1189,7 +1189,7 @@ def test_required_methods(self): required_methods = ("__init__",) for method in required_methods: # pragma: no cover - self.assertIn(method, dir(NearestNeighbourInterpolator)) + assert method in dir(NearestNeighbourInterpolator) def test___init__(self): """ @@ -1202,10 +1202,10 @@ def test___init__(self): x, y, kernel_kwargs={"a": 1} ) - self.assertDictEqual(nearest_neighbour_interpolator.kernel_kwargs, {}) + assert nearest_neighbour_interpolator.kernel_kwargs == {} -class TestLinearInterpolator(unittest.TestCase): +class TestLinearInterpolator: """ Define :class:`colour.algebra.interpolation.LinearInterpolator` class unit tests methods. @@ -1217,7 +1217,7 @@ def test_required_attributes(self): required_attributes = ("x", "y") for attribute in required_attributes: - self.assertIn(attribute, dir(LinearInterpolator)) + assert attribute in dir(LinearInterpolator) def test_required_methods(self): """Test the presence of required methods.""" @@ -1225,7 +1225,7 @@ def test_required_methods(self): required_methods = ("__init__", "__call__") for method in required_methods: # pragma: no cover - self.assertIn(method, dir(LinearInterpolator)) + assert method in dir(LinearInterpolator) def test_raise_exception___init__(self): """ @@ -1234,7 +1234,7 @@ def test_raise_exception___init__(self): """ x, y = np.linspace(0, 1, 10), np.linspace(0, 1, 15) - self.assertRaises(ValueError, LinearInterpolator, x, y) + pytest.raises(ValueError, LinearInterpolator, x, y) def test__call__(self): """ @@ -1272,9 +1272,9 @@ def test_raise_exception___call__(self): x = y = np.linspace(0, 1, 10) linear_interpolator = LinearInterpolator(x, y) - self.assertRaises(ValueError, linear_interpolator, -1) + pytest.raises(ValueError, linear_interpolator, -1) - self.assertRaises(ValueError, linear_interpolator, 11) + pytest.raises(ValueError, linear_interpolator, 11) @ignore_numpy_errors def test_nan__call__(self): @@ -1293,7 +1293,7 @@ def test_nan__call__(self): pass -class TestSpragueInterpolator(unittest.TestCase): +class TestSpragueInterpolator: """ Define :class:`colour.algebra.interpolation.SpragueInterpolator` class unit tests methods. @@ -1305,7 +1305,7 @@ def test_required_attributes(self): required_attributes = ("x", "y") for attribute in required_attributes: - self.assertIn(attribute, dir(SpragueInterpolator)) + assert attribute in dir(SpragueInterpolator) def test_required_methods(self): """Test the presence of required methods.""" @@ -1313,7 +1313,7 @@ def test_required_methods(self): required_methods = ("__init__", "__call__") for method in required_methods: # pragma: no cover - self.assertIn(method, dir(SpragueInterpolator)) + assert method in dir(SpragueInterpolator) def test_raise_exception___init__(self): """ @@ -1322,7 +1322,7 @@ def test_raise_exception___init__(self): """ x, y = np.linspace(0, 1, 10), np.linspace(0, 1, 15) - self.assertRaises(ValueError, SpragueInterpolator, x, y) + pytest.raises(ValueError, SpragueInterpolator, x, y) def test__call__(self): """ @@ -1360,9 +1360,9 @@ def test_raise_exception___call__(self): x = y = np.linspace(0, 1, 10) sprague_interpolator = SpragueInterpolator(x, y) - self.assertRaises(ValueError, sprague_interpolator, -1) + pytest.raises(ValueError, sprague_interpolator, -1) - self.assertRaises(ValueError, sprague_interpolator, 11) + pytest.raises(ValueError, sprague_interpolator, 11) @ignore_numpy_errors def test_nan__call__(self): @@ -1381,7 +1381,7 @@ def test_nan__call__(self): pass -class TestCubicSplineInterpolator(unittest.TestCase): +class TestCubicSplineInterpolator: """ Define :class:`colour.algebra.interpolation.CubicSplineInterpolator` class unit tests methods. @@ -1407,7 +1407,7 @@ def test__call__(self): ) -class TestPchipInterpolator(unittest.TestCase): +class TestPchipInterpolator: """ Define :class:`colour.algebra.interpolation.PchipInterpolator` class unit tests methods. @@ -1419,7 +1419,7 @@ def test_required_attributes(self): required_attributes = ("x", "y") for attribute in required_attributes: - self.assertIn(attribute, dir(PchipInterpolator)) + assert attribute in dir(PchipInterpolator) def test_required_methods(self): """Test the presence of required methods.""" @@ -1427,10 +1427,10 @@ def test_required_methods(self): required_methods = ("__init__",) for method in required_methods: # pragma: no cover - self.assertIn(method, dir(PchipInterpolator)) + assert method in dir(PchipInterpolator) -class TestNullInterpolator(unittest.TestCase): +class TestNullInterpolator: """ Define :class:`colour.algebra.interpolation.NullInterpolator` class unit tests methods. @@ -1442,7 +1442,7 @@ def test_required_attributes(self): required_attributes = ("x", "y") for attribute in required_attributes: - self.assertIn(attribute, dir(NullInterpolator)) + assert attribute in dir(NullInterpolator) def test_required_methods(self): """Test the presence of required methods.""" @@ -1450,7 +1450,7 @@ def test_required_methods(self): required_methods = ("__init__", "__call__") for method in required_methods: # pragma: no cover - self.assertIn(method, dir(NullInterpolator)) + assert method in dir(NullInterpolator) def test_x(self): """ @@ -1514,7 +1514,7 @@ def test_raise_exception___init__(self): """ x, y = np.linspace(0, 1, 10), np.linspace(0, 1, 15) - self.assertRaises(ValueError, NullInterpolator, x, y) + pytest.raises(ValueError, NullInterpolator, x, y) def test__call__(self): """ @@ -1546,9 +1546,9 @@ def test_raise_exception___call__(self): x = y = np.linspace(0, 1, 10) null_interpolator = NullInterpolator(x, y) - self.assertRaises(ValueError, null_interpolator, -1) + pytest.raises(ValueError, null_interpolator, -1) - self.assertRaises(ValueError, null_interpolator, 11) + pytest.raises(ValueError, null_interpolator, 11) @ignore_numpy_errors def test_nan__call__(self): @@ -1567,7 +1567,7 @@ def test_nan__call__(self): pass -class TestLagrangeCoefficients(unittest.TestCase): +class TestLagrangeCoefficients: """ Define :func:`colour.algebra.interpolation.lagrange_coefficients` definition unit tests methods. @@ -1599,7 +1599,7 @@ def test_lagrange_coefficients(self): ) -class TestVerticesAndRelativeCoordinates(unittest.TestCase): +class TestVerticesAndRelativeCoordinates: """ Define :func:`colour.algebra.interpolation.\ vertices_and_relative_coordinates` definition unit tests methods. @@ -1687,7 +1687,7 @@ def test_vertices_and_relative_coordinates(self): ) -class TestTableInterpolationTrilinear(unittest.TestCase): +class TestTableInterpolationTrilinear: """ Define :func:`colour.algebra.interpolation.\ table_interpolation_trilinear` definition unit tests methods. @@ -1729,7 +1729,7 @@ def test_interpolation_trilinear(self): ) -class TestTableInterpolationTetrahedral(unittest.TestCase): +class TestTableInterpolationTetrahedral: """ Define :func:`colour.algebra.interpolation.\ table_interpolation_tetrahedral` definition unit tests methods. @@ -1769,7 +1769,3 @@ def test_interpolation_tetrahedral(self): ), atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/algebra/tests/test_prng.py b/colour/algebra/tests/test_prng.py index a4d326ca0..1245218e5 100644 --- a/colour/algebra/tests/test_prng.py +++ b/colour/algebra/tests/test_prng.py @@ -12,8 +12,6 @@ from __future__ import annotations -import unittest - import numpy as np from colour.algebra import random_triplet_generator @@ -48,7 +46,7 @@ ) -class TestRandomTripletGenerator(unittest.TestCase): +class TestRandomTripletGenerator: """ Define :func:`colour.algebra.prng.random_triplet_generator` definition unit tests methods. @@ -73,7 +71,3 @@ def test_random_triplet_generator(self): random_triplet_generator(10, random_state=prng), atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/algebra/tests/test_regression.py b/colour/algebra/tests/test_regression.py index edf425575..d361b9ada 100644 --- a/colour/algebra/tests/test_regression.py +++ b/colour/algebra/tests/test_regression.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.algebra.regression` module.""" -import unittest import numpy as np @@ -20,7 +19,7 @@ ] -class TestLeastSquareMappingMoorePenrose(unittest.TestCase): +class TestLeastSquareMappingMoorePenrose: """ Define :func:`colour.algebra.regression.\ least_square_mapping_MoorePenrose` definition unit tests methods. @@ -86,7 +85,3 @@ def test_least_square_mapping_MoorePenrose(self): ), atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/appearance/tests/test_atd95.py b/colour/appearance/tests/test_atd95.py index 1bf365e7e..5dd6ab28d 100644 --- a/colour/appearance/tests/test_atd95.py +++ b/colour/appearance/tests/test_atd95.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.appearance.atd95` module.""" -import unittest from itertools import product import numpy as np @@ -26,7 +25,7 @@ ] -class TestXYZ_to_ATD95(unittest.TestCase): +class TestXYZ_to_ATD95: """ Define :func:`colour.appearance.atd95.XYZ_to_ATD95` definition unit tests methods. @@ -203,7 +202,3 @@ def test_nan_XYZ_to_ATD95(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) XYZ_to_ATD95(cases, cases, cases[..., 0], cases[..., 0], cases[..., 0]) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/appearance/tests/test_cam16.py b/colour/appearance/tests/test_cam16.py index 056eb75ff..fc9bece44 100644 --- a/colour/appearance/tests/test_cam16.py +++ b/colour/appearance/tests/test_cam16.py @@ -1,10 +1,10 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.appearance.cam16` module.""" -import unittest from itertools import product import numpy as np +import pytest from colour.appearance import ( VIEWING_CONDITIONS_CAM16, @@ -34,7 +34,7 @@ ] -class TestXYZ_to_CAM16(unittest.TestCase): +class TestXYZ_to_CAM16: """ Define :func:`colour.appearance.cam16.XYZ_to_CAM16` definition unit tests methods. @@ -239,7 +239,7 @@ def test_nan_XYZ_to_CAM16(self): XYZ_to_CAM16(cases, cases, cases[..., 0], cases[..., 0], surround) -class TestCAM16_to_XYZ(unittest.TestCase): +class TestCAM16_to_XYZ: """ Define :func:`colour.appearance.cam16.CAM16_to_XYZ` definition unit tests methods. @@ -395,7 +395,7 @@ def test_raise_exception_CAM16_to_XYZ(self): exception. """ - self.assertRaises( + pytest.raises( ValueError, CAM16_to_XYZ, CAM_Specification_CAM16(41.731207905126638, None, 217.06795976739301), @@ -422,7 +422,3 @@ def test_nan_CAM16_to_XYZ(self): cases[..., 0], surround, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/appearance/tests/test_ciecam02.py b/colour/appearance/tests/test_ciecam02.py index 47ca29c7c..8790a446a 100644 --- a/colour/appearance/tests/test_ciecam02.py +++ b/colour/appearance/tests/test_ciecam02.py @@ -1,10 +1,10 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.appearance.ciecam02` module.""" -import unittest from itertools import product import numpy as np +import pytest from colour.appearance import ( VIEWING_CONDITIONS_CIECAM02, @@ -34,7 +34,7 @@ ] -class TestXYZ_to_CIECAM02(unittest.TestCase): +class TestXYZ_to_CIECAM02: """ Define :func:`colour.appearance.ciecam02.XYZ_to_CIECAM02` definition unit tests methods. @@ -205,7 +205,7 @@ def test_nan_XYZ_to_CIECAM02(self): XYZ_to_CIECAM02(cases, cases, cases[..., 0], cases[..., 0], surround) -class TestCIECAM02_to_XYZ(unittest.TestCase): +class TestCIECAM02_to_XYZ: """ Define :func:`colour.appearance.ciecam02.CIECAM02_to_XYZ` definition unit tests methods. @@ -378,7 +378,7 @@ def test_raise_exception_CIECAM02_to_XYZ(self): raised exception. """ - self.assertRaises( + pytest.raises( ValueError, CIECAM02_to_XYZ, CAM_Specification_CIECAM02(41.731091132513917, None, 219.04843265831178), @@ -407,7 +407,3 @@ def test_nan_CIECAM02_to_XYZ(self): cases[..., 0], surround, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/appearance/tests/test_ciecam16.py b/colour/appearance/tests/test_ciecam16.py index ec72af008..0d555a016 100644 --- a/colour/appearance/tests/test_ciecam16.py +++ b/colour/appearance/tests/test_ciecam16.py @@ -1,10 +1,10 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.appearance.ciecam16` module.""" -import unittest from itertools import product import numpy as np +import pytest from colour.appearance import ( VIEWING_CONDITIONS_CIECAM16, @@ -34,7 +34,7 @@ ] -class TestXYZ_to_CIECAM16(unittest.TestCase): +class TestXYZ_to_CIECAM16: """ Define :func:`colour.appearance.ciecam16.XYZ_to_CIECAM16` definition unit tests methods. @@ -264,7 +264,7 @@ def test_nan_XYZ_to_CIECAM16(self): XYZ_to_CIECAM16(cases, cases, cases[..., 0], cases[..., 0], surround) -class TestCIECAM16_to_XYZ(unittest.TestCase): +class TestCIECAM16_to_XYZ: """ Define :func:`colour.appearance.ciecam16.CIECAM16_to_XYZ` definition unit tests methods. @@ -442,7 +442,7 @@ def test_raise_exception_CIECAM16_to_XYZ(self): raised exception. """ - self.assertRaises( + pytest.raises( ValueError, CIECAM16_to_XYZ, CAM_Specification_CIECAM16(41.731207905126638, None, 217.06795976739301), @@ -471,7 +471,3 @@ def test_nan_CIECAM16_to_XYZ(self): cases[..., 0], surround, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/appearance/tests/test_hellwig2022.py b/colour/appearance/tests/test_hellwig2022.py index 842f68f81..9afee0d8e 100644 --- a/colour/appearance/tests/test_hellwig2022.py +++ b/colour/appearance/tests/test_hellwig2022.py @@ -8,10 +8,10 @@ Discussion with Mansencal, T. """ -import unittest from itertools import product import numpy as np +import pytest from colour.appearance import ( VIEWING_CONDITIONS_HELLWIG2022, @@ -41,7 +41,7 @@ ] -class TestXYZ_to_Hellwig2022(unittest.TestCase): +class TestXYZ_to_Hellwig2022: """ Define :func:`colour.appearance.hellwig2022.XYZ_to_Hellwig2022` definition unit tests methods. @@ -242,7 +242,7 @@ def test_nan_XYZ_to_Hellwig2022(self): XYZ_to_Hellwig2022(cases, cases, cases[..., 0], cases[..., 0], surround) -class TestHellwig2022_to_XYZ(unittest.TestCase): +class TestHellwig2022_to_XYZ: """ Define :func:`colour.appearance.hellwig2022.Hellwig2022_to_XYZ` definition unit tests methods. @@ -414,7 +414,7 @@ def test_raise_exception_Hellwig2022_to_XYZ(self): Test :func:`colour.appearance.hellwig2022.Hellwig2022_to_XYZ` definition raised exception. """ - self.assertRaises( + pytest.raises( ValueError, Hellwig2022_to_XYZ, CAM_Specification_Hellwig2022( @@ -426,7 +426,7 @@ def test_raise_exception_Hellwig2022_to_XYZ(self): VIEWING_CONDITIONS_HELLWIG2022["Average"], ) - self.assertRaises( + pytest.raises( ValueError, Hellwig2022_to_XYZ, CAM_Specification_Hellwig2022(41.731207905126638, None, 217.06795976739301), @@ -455,7 +455,3 @@ def test_nan_Hellwig2022_to_XYZ(self): cases[..., 0], surround, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/appearance/tests/test_hke.py b/colour/appearance/tests/test_hke.py index d3195f82d..8787a9b88 100644 --- a/colour/appearance/tests/test_hke.py +++ b/colour/appearance/tests/test_hke.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.appearance.hke` module.""" -import unittest from itertools import product import numpy as np @@ -30,7 +29,7 @@ ] -class TestHelmholtzKohlrauschEffectObjectNayatani1997(unittest.TestCase): +class TestHelmholtzKohlrauschEffectObjectNayatani1997: """ Define :func:`colour.colour.appearance.hke.\ HelmholtzKohlrausch_effect_object_Nayatani1997` definition unit tests methods. @@ -139,7 +138,7 @@ def test_nan_HelmholtzKohlrausch_effect_object_Nayatani1997(self): HelmholtzKohlrausch_effect_object_Nayatani1997(case, case, case[0]) -class TestHelmholtzKohlrauschEffectLuminousNayatani1997(unittest.TestCase): +class TestHelmholtzKohlrauschEffectLuminousNayatani1997: """ Define :func:`colour.appearance.hke.\ HelmholtzKohlrausch_effect_luminous_Nayatani1997` definition unit tests @@ -249,7 +248,7 @@ def test_nan_HelmholtzKohlrausch_effect_luminous_Nayatani1997(self): HelmholtzKohlrausch_effect_luminous_Nayatani1997(case, case, case[0]) -class TestCoefficient_K_Br_Nayatani1997(unittest.TestCase): +class TestCoefficient_K_Br_Nayatani1997: """ Define :func:`colour.appearance.hke.coefficient_K_Br_Nayatani1997` definition unit tests methods. @@ -329,7 +328,7 @@ def test_nan_coefficient_K_Br_Nayatani1997(self): coefficient_K_Br_Nayatani1997(cases) -class TestCoefficient_q_Nayatani1997(unittest.TestCase): +class TestCoefficient_q_Nayatani1997: """ Define :func:`colour.appearance.hke.coefficient_q_Nayatani1997` definition unit tests methods. @@ -401,7 +400,3 @@ def test_nan_coefficient_q_Nayatani1997(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] coefficient_q_Nayatani1997(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/appearance/tests/test_hunt.py b/colour/appearance/tests/test_hunt.py index f4368e8b5..2aee7cbdb 100644 --- a/colour/appearance/tests/test_hunt.py +++ b/colour/appearance/tests/test_hunt.py @@ -2,7 +2,6 @@ """Define the unit tests for the :mod:`colour.appearance.hunt` module.""" import contextlib -import unittest from itertools import product import numpy as np @@ -31,7 +30,7 @@ ] -class TestXYZ_to_Hunt(unittest.TestCase): +class TestXYZ_to_Hunt: """ Define :func:`colour.appearance.hunt.XYZ_to_Hunt` definition unit tests methods. @@ -242,7 +241,3 @@ def test_nan_XYZ_to_Hunt(self): cases[0, 0], CCT_w=cases, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/appearance/tests/test_kim2009.py b/colour/appearance/tests/test_kim2009.py index 435ae80e1..0fde6e21f 100644 --- a/colour/appearance/tests/test_kim2009.py +++ b/colour/appearance/tests/test_kim2009.py @@ -1,10 +1,10 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.appearance.kim2009` module.""" -import unittest from itertools import product import numpy as np +import pytest from colour.appearance import ( MEDIA_PARAMETERS_KIM2009, @@ -36,7 +36,7 @@ ] -class TestXYZ_to_Kim2009(unittest.TestCase): +class TestXYZ_to_Kim2009: """ Define :func:`colour.appearance.kim2009.XYZ_to_Kim2009` definition unit tests methods. @@ -224,7 +224,7 @@ def test_nan_XYZ_to_Kim2009(self): XYZ_to_Kim2009(cases, cases, cases[0, 0], media, surround) -class TestKim2009_to_XYZ(unittest.TestCase): +class TestKim2009_to_XYZ: """ Define :func:`colour.appearance.kim2009.Kim2009_to_XYZ` definition unit tests methods. @@ -407,7 +407,7 @@ def test_raise_exception_Kim2009_to_XYZ(self): raised exception. """ - self.assertRaises( + pytest.raises( ValueError, Kim2009_to_XYZ, CAM_Specification_Kim2009( @@ -441,7 +441,3 @@ def test_nan_Kim2009_to_XYZ(self): media, surround, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/appearance/tests/test_llab.py b/colour/appearance/tests/test_llab.py index 435ae80e1..0fde6e21f 100644 --- a/colour/appearance/tests/test_llab.py +++ b/colour/appearance/tests/test_llab.py @@ -1,10 +1,10 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.appearance.kim2009` module.""" -import unittest from itertools import product import numpy as np +import pytest from colour.appearance import ( MEDIA_PARAMETERS_KIM2009, @@ -36,7 +36,7 @@ ] -class TestXYZ_to_Kim2009(unittest.TestCase): +class TestXYZ_to_Kim2009: """ Define :func:`colour.appearance.kim2009.XYZ_to_Kim2009` definition unit tests methods. @@ -224,7 +224,7 @@ def test_nan_XYZ_to_Kim2009(self): XYZ_to_Kim2009(cases, cases, cases[0, 0], media, surround) -class TestKim2009_to_XYZ(unittest.TestCase): +class TestKim2009_to_XYZ: """ Define :func:`colour.appearance.kim2009.Kim2009_to_XYZ` definition unit tests methods. @@ -407,7 +407,7 @@ def test_raise_exception_Kim2009_to_XYZ(self): raised exception. """ - self.assertRaises( + pytest.raises( ValueError, Kim2009_to_XYZ, CAM_Specification_Kim2009( @@ -441,7 +441,3 @@ def test_nan_Kim2009_to_XYZ(self): media, surround, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/appearance/tests/test_nayatani95.py b/colour/appearance/tests/test_nayatani95.py index dd8a52104..9d777df46 100644 --- a/colour/appearance/tests/test_nayatani95.py +++ b/colour/appearance/tests/test_nayatani95.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.appearance.nayatani95` module.""" -import unittest from itertools import product import numpy as np @@ -26,7 +25,7 @@ ] -class TestXYZ_to_Nayatani95(unittest.TestCase): +class TestXYZ_to_Nayatani95: """ Define :func:`colour.appearance.nayatani95.XYZ_to_Nayatani95` definition unit tests methods. @@ -157,7 +156,3 @@ def test_nan_XYZ_to_Nayatani95(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) XYZ_to_Nayatani95(cases, cases, cases[..., 0], cases[..., 0], cases[..., 0]) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/appearance/tests/test_rlab.py b/colour/appearance/tests/test_rlab.py index dd8a52104..9d777df46 100644 --- a/colour/appearance/tests/test_rlab.py +++ b/colour/appearance/tests/test_rlab.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.appearance.nayatani95` module.""" -import unittest from itertools import product import numpy as np @@ -26,7 +25,7 @@ ] -class TestXYZ_to_Nayatani95(unittest.TestCase): +class TestXYZ_to_Nayatani95: """ Define :func:`colour.appearance.nayatani95.XYZ_to_Nayatani95` definition unit tests methods. @@ -157,7 +156,3 @@ def test_nan_XYZ_to_Nayatani95(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) XYZ_to_Nayatani95(cases, cases, cases[..., 0], cases[..., 0], cases[..., 0]) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/appearance/tests/test_zcam.py b/colour/appearance/tests/test_zcam.py index dd8a52104..9d777df46 100644 --- a/colour/appearance/tests/test_zcam.py +++ b/colour/appearance/tests/test_zcam.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.appearance.nayatani95` module.""" -import unittest from itertools import product import numpy as np @@ -26,7 +25,7 @@ ] -class TestXYZ_to_Nayatani95(unittest.TestCase): +class TestXYZ_to_Nayatani95: """ Define :func:`colour.appearance.nayatani95.XYZ_to_Nayatani95` definition unit tests methods. @@ -157,7 +156,3 @@ def test_nan_XYZ_to_Nayatani95(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) XYZ_to_Nayatani95(cases, cases, cases[..., 0], cases[..., 0], cases[..., 0]) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/biochemistry/tests/test_michaelis_menten.py b/colour/biochemistry/tests/test_michaelis_menten.py index 23dd8ae14..755cced97 100644 --- a/colour/biochemistry/tests/test_michaelis_menten.py +++ b/colour/biochemistry/tests/test_michaelis_menten.py @@ -3,7 +3,6 @@ module. """ -import unittest from itertools import product import numpy as np @@ -32,7 +31,7 @@ ] -class TestReactionRateMichaelisMentenMichaelis1913(unittest.TestCase): +class TestReactionRateMichaelisMentenMichaelis1913: """ Define :func:`colour.biochemistry.michaelis_menten.\ reaction_rate_MichaelisMenten_Michaelis1913` definition unit tests methods. @@ -112,7 +111,7 @@ def test_nan_reaction_rate_MichaelisMenten_Michaelis1913(self): reaction_rate_MichaelisMenten_Michaelis1913(cases, cases, cases) -class TestSubstrateConcentrationMichaelisMentenMichaelis1913(unittest.TestCase): +class TestSubstrateConcentrationMichaelisMentenMichaelis1913: """ Define :func:`colour.biochemistry.michaelis_menten.\ reaction_rate_MichaelisMenten_Michaelis1913` definition unit tests methods. @@ -194,7 +193,7 @@ def test_nan_substrate_concentration_MichaelisMenten_Michaelis1913(self): substrate_concentration_MichaelisMenten_Michaelis1913(cases, cases, cases) -class TestReactionRateMichaelisMentenAbebe2017(unittest.TestCase): +class TestReactionRateMichaelisMentenAbebe2017: """ Define :func:`colour.biochemistry.michaelis_menten.\ reaction_rate_MichaelisMenten_Abebe2017` definition unit tests methods. @@ -277,7 +276,7 @@ def test_nan_reaction_rate_MichaelisMenten_Abebe2017(self): reaction_rate_MichaelisMenten_Abebe2017(cases, cases, cases, cases) -class TestSubstrateConcentrationMichaelisMentenAbebe2017(unittest.TestCase): +class TestSubstrateConcentrationMichaelisMentenAbebe2017: """ Define :func:`colour.biochemistry.michaelis_menten.\ reaction_rate_MichaelisMenten_Abebe2017` definition unit tests methods. @@ -366,7 +365,3 @@ def test_nan_substrate_concentration_MichaelisMenten_Abebe2017(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) substrate_concentration_MichaelisMenten_Abebe2017(cases, cases, cases, cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/blindness/tests/test_machado2009.py b/colour/blindness/tests/test_machado2009.py index fd419c88b..140e2f3dd 100644 --- a/colour/blindness/tests/test_machado2009.py +++ b/colour/blindness/tests/test_machado2009.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.blindness.machado2009` module.""" -import unittest import numpy as np @@ -30,7 +29,7 @@ ] -class TestMsdsCmfsAnomalousTrichromacyMachado2009(unittest.TestCase): +class TestMsdsCmfsAnomalousTrichromacyMachado2009: """ Define :func:`colour.blindness.machado2009.\ msds_cmfs_anomalous_trichromacy_Machado2009` definition unit tests methods. @@ -121,7 +120,7 @@ def test_msds_cmfs_anomalous_trichromacy_Machado2009(self): ) -class TestMatrixAnomalousTrichromacyMachado2009(unittest.TestCase): +class TestMatrixAnomalousTrichromacyMachado2009: """ Define :func:`colour.blindness.machado2009.\ matrix_anomalous_trichromacy_Machado2009` definition unit tests methods. @@ -216,7 +215,7 @@ def test_matrix_anomalous_trichromacy_Machado2009(self): ) -class TestMatrixCvdMachado2009(unittest.TestCase): +class TestMatrixCvdMachado2009: """ Define :func:`colour.blindness.machado2009.matrix_cvd_Machado2009` definition unit tests methods. @@ -285,7 +284,3 @@ def test_nan_matrix_cvd_Machado2009(self): for case in [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]: matrix_cvd_Machado2009("Tritanomaly", case) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/characterisation/tests/test_aces_it.py b/colour/characterisation/tests/test_aces_it.py index eca63d412..e00b58cbc 100644 --- a/colour/characterisation/tests/test_aces_it.py +++ b/colour/characterisation/tests/test_aces_it.py @@ -6,7 +6,6 @@ from __future__ import annotations import os -import unittest import numpy as np @@ -87,7 +86,7 @@ )["iso7589"] -class TestSdToAcesRelativeExposureValues(unittest.TestCase): +class TestSdToAcesRelativeExposureValues: """ Define :func:`colour.characterisation.aces_it.\ sd_to_aces_relative_exposure_values` definition unit tests methods. @@ -165,7 +164,7 @@ def test_domain_range_scale_spectral_to_aces_relative_exposure_values( ) -class TestReadTrainingDataRawtoacesV1(unittest.TestCase): +class TestReadTrainingDataRawtoacesV1: """ Define :func:`colour.characterisation.aces_it.\ read_training_data_rawtoaces_v1` definition unit tests methods. @@ -177,10 +176,10 @@ def test_read_training_data_rawtoaces_v1(self): read_training_data_rawtoaces_v1` definition. """ - self.assertEqual(len(read_training_data_rawtoaces_v1().labels), 190) + assert len(read_training_data_rawtoaces_v1().labels) == 190 -class TestGenerateIlluminantsRawtoacesV1(unittest.TestCase): +class TestGenerateIlluminantsRawtoacesV1: """ Define :func:`colour.characterisation.aces_it.\ generate_illuminants_rawtoaces_v1` definition unit tests methods. @@ -192,64 +191,61 @@ def test_generate_illuminants_rawtoaces_v1(self): generate_illuminants_rawtoaces_v1` definition. """ - self.assertListEqual( - sorted(generate_illuminants_rawtoaces_v1().keys()), - [ - "1000K Blackbody", - "1500K Blackbody", - "2000K Blackbody", - "2500K Blackbody", - "3000K Blackbody", - "3500K Blackbody", - "D100", - "D105", - "D110", - "D115", - "D120", - "D125", - "D130", - "D135", - "D140", - "D145", - "D150", - "D155", - "D160", - "D165", - "D170", - "D175", - "D180", - "D185", - "D190", - "D195", - "D200", - "D205", - "D210", - "D215", - "D220", - "D225", - "D230", - "D235", - "D240", - "D245", - "D250", - "D40", - "D45", - "D50", - "D55", - "D60", - "D65", - "D70", - "D75", - "D80", - "D85", - "D90", - "D95", - "iso7589", - ], - ) - - -class TestWhiteBalanceMultipliers(unittest.TestCase): + assert sorted(generate_illuminants_rawtoaces_v1().keys()) == [ + "1000K Blackbody", + "1500K Blackbody", + "2000K Blackbody", + "2500K Blackbody", + "3000K Blackbody", + "3500K Blackbody", + "D100", + "D105", + "D110", + "D115", + "D120", + "D125", + "D130", + "D135", + "D140", + "D145", + "D150", + "D155", + "D160", + "D165", + "D170", + "D175", + "D180", + "D185", + "D190", + "D195", + "D200", + "D205", + "D210", + "D215", + "D220", + "D225", + "D230", + "D235", + "D240", + "D245", + "D250", + "D40", + "D45", + "D50", + "D55", + "D60", + "D65", + "D70", + "D75", + "D80", + "D85", + "D90", + "D95", + "iso7589", + ] + + +class TestWhiteBalanceMultipliers: """ Define :func:`colour.characterisation.aces_it.white_balance_multipliers` definition unit tests methods. @@ -277,7 +273,7 @@ def test_white_balance_multipliers(self): ) -class TestBestIlluminant(unittest.TestCase): +class TestBestIlluminant: """ Define :func:`colour.characterisation.aces_it.best_illuminant` definition unit tests methods. @@ -289,30 +285,30 @@ def test_best_illuminant(self): definition. """ - self.assertEqual( + assert ( best_illuminant( white_balance_multipliers( MSDS_CANON_EOS_5DMARK_II, SDS_ILLUMINANTS["FL2"] ), MSDS_CANON_EOS_5DMARK_II, generate_illuminants_rawtoaces_v1(), - ).name, - "D40", + ).name + == "D40" ) - self.assertEqual( + assert ( best_illuminant( white_balance_multipliers( MSDS_CANON_EOS_5DMARK_II, SDS_ILLUMINANTS["A"] ), MSDS_CANON_EOS_5DMARK_II, generate_illuminants_rawtoaces_v1(), - ).name, - "3000K Blackbody", + ).name + == "3000K Blackbody" ) -class TestNormaliseIlluminant(unittest.TestCase): +class TestNormaliseIlluminant: """ Define :func:`colour.characterisation.aces_it.normalise_illuminant` definition unit tests methods. @@ -335,7 +331,7 @@ def test_normalise_illuminant(self): ) -class TestTrainingDataSdsToRGB(unittest.TestCase): +class TestTrainingDataSdsToRGB: """ Define :func:`colour.characterisation.aces_it.training_data_sds_to_RGB` definition unit tests methods. @@ -603,7 +599,7 @@ def test_training_data_sds_to_RGB(self): ) -class TestTrainingDataSdsToXYZ(unittest.TestCase): +class TestTrainingDataSdsToXYZ: """ Define :func:`colour.characterisation.aces_it.training_data_sds_to_XYZ` definition unit tests methods. @@ -898,7 +894,7 @@ def test_training_data_sds_to_XYZ(self): ) -class TestWhitepointPreservingMatrix(unittest.TestCase): +class TestWhitepointPreservingMatrix: """ Define :func:`colour.characterisation.aces_it.whitepoint_preserving_matrix` definition unit tests methods. @@ -928,7 +924,7 @@ def test_whitepoint_preserving_matrix(self): ) -class TestOptimizationFactoryRawtoacesV1(unittest.TestCase): +class TestOptimizationFactoryRawtoacesV1: """ Define :func:`colour.characterisation.aces_it.\ optimisation_factory_rawtoaces_v1` definition unit tests methods. @@ -940,10 +936,10 @@ def test_optimisation_factory_rawtoaces_v1(self): optimisation_factory_rawtoaces_v1` definition. """ - self.assertEqual(len(optimisation_factory_rawtoaces_v1()), 4) + assert len(optimisation_factory_rawtoaces_v1()) == 4 -class TestOptimizationFactoryJzazbz(unittest.TestCase): +class TestOptimizationFactoryJzazbz: """ Define :func:`colour.characterisation.aces_it.\ optimisation_factory_Jzazbz` definition unit tests methods. @@ -955,10 +951,10 @@ def test_optimisation_factory_Jzazbz(self): optimisation_factory_Jzazbz` definition. """ - self.assertEqual(len(optimisation_factory_Jzazbz()), 4) + assert len(optimisation_factory_Jzazbz()) == 4 -class TestOptimizationFactoryOklab18(unittest.TestCase): +class TestOptimizationFactoryOklab18: """ Define :func:`colour.characterisation.aces_it.\ optimisation_factory_Oklab_15` definition unit tests methods. @@ -970,10 +966,10 @@ def test_optimisation_factory_Oklab_18(self): optimisation_factory_Oklab_15` definition. """ - self.assertEqual(len(optimisation_factory_Oklab_15()), 4) + assert len(optimisation_factory_Oklab_15()) == 4 -class TestMatrixIdt(unittest.TestCase): +class TestMatrixIdt: """ Define :func:`colour.characterisation.aces_it.matrix_idt` definition unit tests methods. @@ -1184,7 +1180,7 @@ def test_matrix_idt(self): ) -class TestCamera_RGB_to_ACES2065_1(unittest.TestCase): +class TestCamera_RGB_to_ACES2065_1: """ Define :func:`colour.characterisation.aces_it.camera_RGB_to_ACES2065_1` definition unit tests methods. @@ -1214,7 +1210,3 @@ def test_camera_RGB_to_ACES2065_1(self): np.array([2.24358784, 0.98311459, 1.64045840]), atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/characterisation/tests/test_correction.py b/colour/characterisation/tests/test_correction.py index a31c5bdb2..9c76bc242 100644 --- a/colour/characterisation/tests/test_correction.py +++ b/colour/characterisation/tests/test_correction.py @@ -7,10 +7,10 @@ import contextlib import platform -import unittest from itertools import product import numpy as np +import pytest from numpy.linalg import LinAlgError from colour.characterisation.correction import ( @@ -114,7 +114,7 @@ ) -class TestMatrixAugmentedCheung2004(unittest.TestCase): +class TestMatrixAugmentedCheung2004: """ Define :func:`colour.characterisation.correction.\ matrix_augmented_Cheung2004` definition unit tests methods. @@ -370,7 +370,7 @@ def test_raise_exception_matrix_augmented_Cheung2004(self): matrix_augmented_Cheung2004` definition raised exception. """ - self.assertRaises( + pytest.raises( ValueError, matrix_augmented_Cheung2004, np.array([0.17224810, 0.09170660, 0.06416938]), @@ -389,7 +389,7 @@ def test_nan_matrix_augmented_Cheung2004(self): matrix_augmented_Cheung2004(cases) -class TestPolynomialExpansionFinlayson2015(unittest.TestCase): +class TestPolynomialExpansionFinlayson2015: """ Define :func:`colour.characterisation.correction.\ polynomial_expansion_Finlayson2015` definition unit tests methods. @@ -561,7 +561,7 @@ def test_raise_exception_polynomial_expansion_Finlayson2015(self): polynomial_expansion_Finlayson2015` definition raised exception. """ - self.assertRaises( + pytest.raises( ValueError, polynomial_expansion_Finlayson2015, np.array([0.17224810, 0.09170660, 0.06416938]), @@ -580,7 +580,7 @@ def test_nan_polynomial_expansion_Finlayson2015(self): polynomial_expansion_Finlayson2015(cases) -class TestPolynomialExpansionVandermonde(unittest.TestCase): +class TestPolynomialExpansionVandermonde: """ Define :func:`colour.characterisation.correction.\ polynomial_expansion_Vandermonde` definition unit tests methods. @@ -659,7 +659,7 @@ def test_nan_polynomial_expansion_Vandermonde(self): polynomial_expansion_Vandermonde(cases) -class TestMatrixColourCorrectionCheung2004(unittest.TestCase): +class TestMatrixColourCorrectionCheung2004: """ Define :func:`colour.characterisation.correction.\ matrix_colour_correction_Cheung2004` definition unit tests methods. @@ -740,7 +740,7 @@ def test_nan_matrix_colour_correction_Cheung2004(self): # pragma: no cover ) -class TestMatrixColourCorrectionFinlayson2015(unittest.TestCase): +class TestMatrixColourCorrectionFinlayson2015: """ Define :func:`colour.characterisation.correction.\ matrix_colour_correction_Finlayson2015` definition unit tests methods. @@ -843,7 +843,7 @@ def test_nan_matrix_colour_correction_Finlayson2015( ) -class TestMatrixColourCorrectionVandermonde(unittest.TestCase): +class TestMatrixColourCorrectionVandermonde: """ Define :func:`colour.characterisation.correction.\ matrix_colour_correction_Vandermonde` definition unit tests methods. @@ -937,7 +937,7 @@ def test_nan_matrix_colour_correction_Vandermonde( ) -class TestApplyMatrixColourCorrectionCheung2004(unittest.TestCase): +class TestApplyMatrixColourCorrectionCheung2004: """ Define :func:`colour.characterisation.correction.\ apply_matrix_colour_correction_Cheung2004` definition unit tests methods. @@ -1021,7 +1021,7 @@ def test_nan_apply_matrix_colour_correction_Cheung2004( ) -class TestApplyMatrixColourCorrectionFinlayson2015(unittest.TestCase): +class TestApplyMatrixColourCorrectionFinlayson2015: """ Define :func:`colour.characterisation.correction.\ apply_matrix_colour_correction_Finlayson2015` definition unit tests methods. @@ -1105,7 +1105,7 @@ def test_nan_apply_matrix_colour_correction_Finlayson2015( ) -class TestApplyMatrixColourCorrectionVandermonde(unittest.TestCase): +class TestApplyMatrixColourCorrectionVandermonde: """ Define :func:`colour.characterisation.correction.\ apply_matrix_colour_correction_Vandermonde` definition unit tests methods. @@ -1189,7 +1189,7 @@ def test_nan_apply_matrix_colour_correction_Vandermonde( ) -class TestColourCorrectionCheung2004(unittest.TestCase): +class TestColourCorrectionCheung2004: """ Define :func:`colour.characterisation.correction.\ colour_correction_Cheung2004` definition unit tests methods. @@ -1262,7 +1262,7 @@ def test_nan_colour_correction_Cheung2004(self): # pragma: no cover ) -class TestColourCorrectionFinlayson2015(unittest.TestCase): +class TestColourCorrectionFinlayson2015: """ Define :func:`colour.characterisation.correction.\ colour_correction_Finlayson2015` definition unit tests methods. @@ -1337,7 +1337,7 @@ def test_nan_colour_correction_Finlayson2015(self): # pragma: no cover ) -class TestColourCorrectionVandermonde(unittest.TestCase): +class TestColourCorrectionVandermonde: """ Define :func:`colour.characterisation.correction.\ colour_correction_Vandermonde` definition unit tests methods. @@ -1408,7 +1408,3 @@ def test_nan_colour_correction_Vandermonde(self): # pragma: no cover np.vstack([case, case, case]), np.transpose(np.vstack([case, case, case])), ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/colorimetry/tests/test_blackbody.py b/colour/colorimetry/tests/test_blackbody.py index afb9e34c3..34ffeb5b7 100644 --- a/colour/colorimetry/tests/test_blackbody.py +++ b/colour/colorimetry/tests/test_blackbody.py @@ -3,10 +3,10 @@ from __future__ import annotations -import unittest from itertools import product import numpy as np +import pytest from colour.colorimetry import ( SpectralShape, @@ -1197,7 +1197,7 @@ ) -class TestPlanckLaw(unittest.TestCase): +class TestPlanckLaw: """ Define :func:`colour.colorimetry.blackbody.planck_law` definition unit tests methods. @@ -1268,7 +1268,7 @@ def test_raise_exception_planck_law(self): """ for wavelength in [-1.0, 0.0, -np.inf, np.nan]: - self.assertRaises(AssertionError, planck_law, wavelength, 5500) + pytest.raises(AssertionError, planck_law, wavelength, 5500) @ignore_numpy_errors def test_nan_planck_law(self): @@ -1283,7 +1283,7 @@ def test_nan_planck_law(self): planck_law(cases, cases) -class TestSdBlackbody(unittest.TestCase): +class TestSdBlackbody: """ Define :func:`colour.colorimetry.blackbody.sd_blackbody` definition unit tests methods. @@ -1299,7 +1299,7 @@ def test_sd_blackbody(self): ) -class TestRayleighJeansLaw(unittest.TestCase): +class TestRayleighJeansLaw: """ Define :func:`colour.colorimetry.blackbody.rayleigh_jeans_law` definition unit tests methods. @@ -1378,7 +1378,7 @@ def test_nan_rayleigh_jeans_law(self): rayleigh_jeans_law(cases, cases) -class TestSdRayleighJeans(unittest.TestCase): +class TestSdRayleighJeans: """ Define :func:`colour.colorimetry.blackbody.sd_rayleigh_jeans` definition unit tests methods. @@ -1395,7 +1395,3 @@ def test_sd_rayleigh_jeans(self): DATA_RAYLEIGH_JEANS, atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/colorimetry/tests/test_correction.py b/colour/colorimetry/tests/test_correction.py index 9956d308f..9d2e66dc2 100644 --- a/colour/colorimetry/tests/test_correction.py +++ b/colour/colorimetry/tests/test_correction.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.colorimetry.correction` module.""" -import unittest import numpy as np @@ -63,7 +62,7 @@ ) -class TestBandpassCorrectionStearns1988(unittest.TestCase): +class TestBandpassCorrectionStearns1988: """ Define :func:`colour.colorimetry.correction.\ bandpass_correction_Stearns1988` definition unit tests methods. @@ -89,7 +88,3 @@ def test_bandpass_correction_Stearns1988(self): DATA_BANDPASS_CORRECTED, atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/colorimetry/tests/test_dominant.py b/colour/colorimetry/tests/test_dominant.py index 47f659ef1..695c7bf18 100644 --- a/colour/colorimetry/tests/test_dominant.py +++ b/colour/colorimetry/tests/test_dominant.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.colorimetry.dominant` module.""" -import unittest from itertools import product import numpy as np @@ -37,13 +36,13 @@ ] -class TestClosestSpectralLocusWavelength(unittest.TestCase): +class TestClosestSpectralLocusWavelength: """ Define :func:`colour.colorimetry.dominant.\ closest_spectral_locus_wavelength` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._xy_s = XYZ_to_xy(MSDS_CMFS["CIE 1931 2 Degree Standard Observer"].values) @@ -60,7 +59,7 @@ def test_closest_spectral_locus_wavelength(self): xy_n = self._xy_D65 i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s) - self.assertEqual(i_wl, np.array(256)) + assert i_wl == np.array(256) np.testing.assert_allclose( xy_wl, np.array([0.68354746, 0.31628409]), @@ -70,7 +69,7 @@ def test_closest_spectral_locus_wavelength(self): xy = np.array([0.37605506, 0.24452225]) i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s) - self.assertEqual(i_wl, np.array(248)) + assert i_wl == np.array(248) np.testing.assert_allclose( xy_wl, np.array([0.45723147, 0.13628148]), @@ -119,13 +118,13 @@ def test_nan_closest_spectral_locus_wavelength(self): closest_spectral_locus_wavelength(case, case, self._xy_s) -class TestDominantWavelength(unittest.TestCase): +class TestDominantWavelength: """ Define :func:`colour.colorimetry.dominant.dominant_wavelength` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._xy_D65 = CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"] @@ -140,7 +139,7 @@ def test_dominant_wavelength(self): xy_n = self._xy_D65 wl, xy_wl, xy_cwl = dominant_wavelength(xy, xy_n) - self.assertEqual(wl, np.array(616.0)) + assert wl == np.array(616.0) np.testing.assert_allclose( xy_wl, np.array([0.68354746, 0.31628409]), @@ -155,7 +154,7 @@ def test_dominant_wavelength(self): xy = np.array([0.37605506, 0.24452225]) i_wl, xy_wl, xy_cwl = dominant_wavelength(xy, xy_n) - self.assertEqual(i_wl, np.array(-509.0)) + assert i_wl == np.array(-509.0) np.testing.assert_allclose( xy_wl, np.array([0.45723147, 0.13628148]), @@ -218,13 +217,13 @@ def test_nan_dominant_wavelength(self): dominant_wavelength(case, case) -class TestComplementaryWavelength(unittest.TestCase): +class TestComplementaryWavelength: """ Define :func:`colour.colorimetry.dominant.complementary_wavelength` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._xy_D65 = CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"] @@ -239,7 +238,7 @@ def test_complementary_wavelength(self): xy_n = self._xy_D65 wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n) - self.assertEqual(wl, np.array(492.0)) + assert wl == np.array(492.0) np.testing.assert_allclose( xy_wl, np.array([0.03647950, 0.33847127]), @@ -254,7 +253,7 @@ def test_complementary_wavelength(self): xy = np.array([0.37605506, 0.24452225]) i_wl, xy_wl, xy_cwl = complementary_wavelength(xy, xy_n) - self.assertEqual(i_wl, np.array(509.0)) + assert i_wl == np.array(509.0) np.testing.assert_allclose( xy_wl, np.array([0.01040962, 0.73207453]), @@ -317,13 +316,13 @@ def test_nan_complementary_wavelength(self): complementary_wavelength(case, case) -class TestExcitationPurity(unittest.TestCase): +class TestExcitationPurity: """ Define :func:`colour.colorimetry.dominant.excitation_purity` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._xy_D65 = CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"] @@ -384,13 +383,13 @@ def test_nan_excitation_purity(self): excitation_purity(case, case) -class TestColorimetricPurity(unittest.TestCase): +class TestColorimetricPurity: """ Define :func:`colour.colorimetry.dominant.colorimetric_purity` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._xy_D65 = CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"] @@ -452,7 +451,3 @@ def test_nan_colorimetric_purity(self): cases = np.array(list(set(product(cases, repeat=2)))) for case in cases: colorimetric_purity(case, case) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/colorimetry/tests/test_generation.py b/colour/colorimetry/tests/test_generation.py index 16518e106..248fde67d 100644 --- a/colour/colorimetry/tests/test_generation.py +++ b/colour/colorimetry/tests/test_generation.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.colorimetry.generation` module.""" -import unittest import numpy as np @@ -40,7 +39,7 @@ ] -class TestSdConstant(unittest.TestCase): +class TestSdConstant: """ Define :func:`colour.colorimetry.generation.sd_constant` definition unit tests methods. @@ -58,7 +57,7 @@ def test_sd_constant(self): np.testing.assert_allclose(sd[780], np.pi, atol=TOLERANCE_ABSOLUTE_TESTS) -class TestSdZeros(unittest.TestCase): +class TestSdZeros: """ Define :func:`colour.colorimetry.generation.sd_zeros` definition unit tests methods. @@ -72,14 +71,14 @@ def test_sd_zeros(self): sd = sd_zeros() - self.assertEqual(sd[360], 0) + assert sd[360] == 0 - self.assertEqual(sd[555], 0) + assert sd[555] == 0 - self.assertEqual(sd[780], 0) + assert sd[780] == 0 -class TestSdOnes(unittest.TestCase): +class TestSdOnes: """ Define :func:`colour.colorimetry.generation.sd_ones` definition unit tests methods. @@ -90,14 +89,14 @@ def test_sd_ones(self): sd = sd_ones() - self.assertEqual(sd[360], 1) + assert sd[360] == 1 - self.assertEqual(sd[555], 1) + assert sd[555] == 1 - self.assertEqual(sd[780], 1) + assert sd[780] == 1 -class TestMsdsConstant(unittest.TestCase): +class TestMsdsConstant: """ Define :func:`colour.colorimetry.generation.msds_constant` definition unit tests methods. @@ -127,7 +126,7 @@ def test_msds_constant(self): ) -class TestMsdsZeros(unittest.TestCase): +class TestMsdsZeros: """ Define :func:`colour.colorimetry.generation.msds_zeros` definition unit tests methods. @@ -148,7 +147,7 @@ def test_msds_zeros(self): np.testing.assert_equal(msds[780], np.array([0, 0, 0])) -class TestMsdsOnes(unittest.TestCase): +class TestMsdsOnes: """ Define :func:`colour.colorimetry.generation.msds_ones` definition unit tests methods. @@ -166,7 +165,7 @@ def test_msds_ones(self): np.testing.assert_equal(msds[780], np.array([1, 1, 1])) -class TestSdGaussianNormal(unittest.TestCase): +class TestSdGaussianNormal: """ Define :func:`colour.colorimetry.generation.sd_gaussian_normal` definition unit tests methods. @@ -191,7 +190,7 @@ def test_sd_gaussian_normal(self): ) -class TestSdGaussianFwhm(unittest.TestCase): +class TestSdGaussianFwhm: """ Define :func:`colour.colorimetry.generation.sd_gaussian_fwhm` definition unit tests methods. @@ -215,7 +214,7 @@ def test_sd_gaussian_fwhm(self): np.testing.assert_allclose(sd[555 - 25 / 2], 0.5, atol=TOLERANCE_ABSOLUTE_TESTS) -class TestSdSingleLedOhno2005(unittest.TestCase): +class TestSdSingleLedOhno2005: """ Define :func:`colour.colorimetry.generation.sd_single_led_Ohno2005` definition unit tests methods. @@ -240,7 +239,7 @@ def test_sd_single_led_Ohno2005(self): ) -class TestSdMultiLedsOhno2005(unittest.TestCase): +class TestSdMultiLedsOhno2005: """ Define :func:`colour.colorimetry.generation.sd_multi_leds_Ohno2005` definition unit tests methods. @@ -286,7 +285,3 @@ def test_sd_multi_leds_Ohno2005(self): np.testing.assert_allclose( sd[640], 0.070140708922879, atol=TOLERANCE_ABSOLUTE_TESTS ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/colorimetry/tests/test_illuminants.py b/colour/colorimetry/tests/test_illuminants.py index 254bc527e..68954b08c 100644 --- a/colour/colorimetry/tests/test_illuminants.py +++ b/colour/colorimetry/tests/test_illuminants.py @@ -3,8 +3,6 @@ from __future__ import annotations -import unittest - import numpy as np from colour.colorimetry import ( @@ -134,7 +132,7 @@ ) -class TestSdCIEStandardIlluminantA(unittest.TestCase): +class TestSdCIEStandardIlluminantA: """ Define :func:`colour.colorimetry.illuminants.\ sd_CIE_standard_illuminant_A` definition unit tests methods. @@ -153,7 +151,7 @@ def test_sd_CIE_standard_illuminant_A(self): ) -class TestSdCIEIlluminantDSeries(unittest.TestCase): +class TestSdCIEIlluminantDSeries: """ Define :func:`colour.colorimetry.illuminants.sd_CIE_illuminant_D_series` definition unit tests methods. @@ -183,7 +181,7 @@ def test_sd_CIE_illuminant_D_series(self): ) -class TestDaylightLocusFunction(unittest.TestCase): +class TestDaylightLocusFunction: """ Define :func:`colour.colorimetry.illuminants.daylight_locus_function` definition unit tests methods. @@ -243,7 +241,3 @@ def test_nan_daylight_locus_function(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] daylight_locus_function(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/colorimetry/tests/test_lefs.py b/colour/colorimetry/tests/test_lefs.py index d0a7ce30a..2207bc24a 100644 --- a/colour/colorimetry/tests/test_lefs.py +++ b/colour/colorimetry/tests/test_lefs.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.colorimetry.lefs` module.""" -import unittest import numpy as np @@ -430,7 +429,7 @@ ) -class TestMesopicWeightingFunction(unittest.TestCase): +class TestMesopicWeightingFunction: """ Define :func:`colour.colorimetry.lefs.mesopic_weighting_function` definition unit tests methods. @@ -507,7 +506,7 @@ def test_nan_mesopic_weighting_function(self): ) -class TestSdMesopicLuminousEfficiencyFunction(unittest.TestCase): +class TestSdMesopicLuminousEfficiencyFunction: """ Define :func:`colour.colorimetry.lefs.\ sd_mesopic_luminous_efficiency_function` definition unit tests methods. @@ -524,7 +523,3 @@ def test_sd_mesopic_luminous_efficiency_function(self): DATA_MESOPIC_LEF, atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/colorimetry/tests/test_lightness.py b/colour/colorimetry/tests/test_lightness.py index 4f5e59743..317eca3ca 100644 --- a/colour/colorimetry/tests/test_lightness.py +++ b/colour/colorimetry/tests/test_lightness.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.colorimetry.lightness` module.""" -import unittest import numpy as np @@ -37,7 +36,7 @@ ] -class TestLightnessGlasser1958(unittest.TestCase): +class TestLightnessGlasser1958: """ Define :func:`colour.colorimetry.lightness.lightness_Glasser1958` definition unit tests methods. @@ -121,7 +120,7 @@ def test_nan_lightness_Glasser1958(self): lightness_Glasser1958(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLightnessWyszecki1963(unittest.TestCase): +class TestLightnessWyszecki1963: """ Define :func:`colour.colorimetry.lightness.lightness_Wyszecki1963` definition unit tests methods. @@ -205,7 +204,7 @@ def test_nan_lightness_Wyszecki1963(self): lightness_Wyszecki1963(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestIntermediateLightnessFunctionCIE1976(unittest.TestCase): +class TestIntermediateLightnessFunctionCIE1976: """ Define :func:`colour.colorimetry.lightness.\ intermediate_lightness_function_CIE1976` definition unit tests methods. @@ -298,7 +297,7 @@ def test_nan_intermediate_lightness_function_CIE1976(self): ) -class TestLightnessCIE1976(unittest.TestCase): +class TestLightnessCIE1976: """ Define :func:`colour.colorimetry.lightness.lightness_CIE1976` definition unit tests methods. @@ -400,7 +399,7 @@ def test_nan_lightness_CIE1976(self): lightness_CIE1976(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLightnessFairchild2010(unittest.TestCase): +class TestLightnessFairchild2010: """ Define :func:`colour.colorimetry.lightness.lightness_Fairchild2010` definition unit tests methods. @@ -502,7 +501,7 @@ def test_nan_lightness_Fairchild2010(self): lightness_Fairchild2010(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLightnessFairchild2011(unittest.TestCase): +class TestLightnessFairchild2011: """ Define :func:`colour.colorimetry.lightness.lightness_Fairchild2011` definition unit tests methods. @@ -604,7 +603,7 @@ def test_nan_lightness_Fairchild2011(self): lightness_Fairchild2011(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLightnessAbebe2017(unittest.TestCase): +class TestLightnessAbebe2017: """ Define :func:`colour.colorimetry.lightness.lightness_Abebe2017` definition unit tests methods. @@ -700,7 +699,7 @@ def test_nan_lightness_Abebe2017(self): lightness_Abebe2017(*[np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])] * 2) -class TestLightness(unittest.TestCase): +class TestLightness: """ Define :func:`colour.colorimetry.lightness.lightness` definition unit tests methods. @@ -731,7 +730,3 @@ def test_domain_range_scale_lightness(self): value * factor, atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/colorimetry/tests/test_luminance.py b/colour/colorimetry/tests/test_luminance.py index 58ee2a583..de7ab588a 100644 --- a/colour/colorimetry/tests/test_luminance.py +++ b/colour/colorimetry/tests/test_luminance.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.colorimetry.luminance` module.""" -import unittest import numpy as np @@ -37,7 +36,7 @@ ] -class TestLuminanceNewhall1943(unittest.TestCase): +class TestLuminanceNewhall1943: """ Define :func:`colour.colorimetry.luminance.luminance_Newhall1943` definition unit tests methods. @@ -121,7 +120,7 @@ def test_nan_luminance_Newhall1943(self): luminance_Newhall1943(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLuminanceASTMD1535(unittest.TestCase): +class TestLuminanceASTMD1535: """ Define :func:`colour.colorimetry.luminance.luminance_ASTMD1535` definition unit tests methods. @@ -205,7 +204,7 @@ def test_nan_luminance_ASTMD1535(self): luminance_ASTMD1535(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestIntermediateLuminanceFunctionCIE1976(unittest.TestCase): +class TestIntermediateLuminanceFunctionCIE1976: """ Define :func:`colour.colorimetry.luminance.\ intermediate_luminance_function_CIE1976` definition unit tests methods. @@ -298,7 +297,7 @@ def test_nan_intermediate_luminance_function_CIE1976(self): ) -class TestLuminanceCIE1976(unittest.TestCase): +class TestLuminanceCIE1976: """ Define :func:`colour.colorimetry.luminance.luminance_CIE1976` definition unit tests methods. @@ -400,7 +399,7 @@ def test_nan_luminance_CIE1976(self): luminance_CIE1976(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLuminanceFairchild2010(unittest.TestCase): +class TestLuminanceFairchild2010: """ Define :func:`colour.colorimetry.luminance.luminance_Fairchild2010` definition unit tests methods. @@ -502,7 +501,7 @@ def test_nan_luminance_Fairchild2010(self): luminance_Fairchild2010(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLuminanceFairchild2011(unittest.TestCase): +class TestLuminanceFairchild2011: """ Define :func:`colour.colorimetry.luminance.luminance_Fairchild2011` definition unit tests methods. @@ -604,7 +603,7 @@ def test_nan_luminance_Fairchild2011(self): luminance_Fairchild2011(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLuminanceAbebe2017(unittest.TestCase): +class TestLuminanceAbebe2017: """ Define :func:`colour.colorimetry.luminance.luminance_Abebe2017` definition unit tests methods. @@ -700,7 +699,7 @@ def test_nan_luminance_Abebe2017(self): luminance_Abebe2017(*[np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])] * 2) -class TestLuminance(unittest.TestCase): +class TestLuminance: """ Define :func:`colour.colorimetry.luminance.luminance` definition unit tests methods. @@ -733,7 +732,3 @@ def test_domain_range_scale_luminance(self): value * factor, atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/colorimetry/tests/test_photometry.py b/colour/colorimetry/tests/test_photometry.py index a4cc8d40d..d87e47562 100644 --- a/colour/colorimetry/tests/test_photometry.py +++ b/colour/colorimetry/tests/test_photometry.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.colorimetry.photometry` module.""" -import unittest import numpy as np @@ -29,7 +28,7 @@ ] -class TestLuminousFlux(unittest.TestCase): +class TestLuminousFlux: """ Define :func:`colour.colorimetry.photometry.luminous_flux` definition unit tests methods. @@ -57,7 +56,7 @@ def test_luminous_flux(self): ) -class TestLuminousEfficiency(unittest.TestCase): +class TestLuminousEfficiency: """ Define :func:`colour.colorimetry.photometry.luminous_efficiency` definition unit tests methods. @@ -88,7 +87,7 @@ def test_luminous_efficiency(self): ) -class TestLuminousEfficacy(unittest.TestCase): +class TestLuminousEfficacy: """ Define :func:`colour.colorimetry.photometry.luminous_efficacy` definition unit tests methods. @@ -123,7 +122,3 @@ def test_luminous_efficacy(self): np.testing.assert_allclose( luminous_efficacy(sd), 683.00000000, atol=TOLERANCE_ABSOLUTE_TESTS ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/colorimetry/tests/test_spectrum.py b/colour/colorimetry/tests/test_spectrum.py index 7cb7ff547..e82743cf0 100644 --- a/colour/colorimetry/tests/test_spectrum.py +++ b/colour/colorimetry/tests/test_spectrum.py @@ -2,9 +2,9 @@ """Define the unit tests for the :mod:`colour.colorimetry.spectrum` module.""" import pickle -import unittest import numpy as np +import pytest import colour from colour.algebra import CubicSplineInterpolator @@ -1248,7 +1248,7 @@ } -class TestSpectralShape(unittest.TestCase): +class TestSpectralShape: """ Define :class:`colour.colorimetry.spectrum.SpectralShape` class unit tests methods. @@ -1266,7 +1266,7 @@ def test_required_attributes(self): ) for attribute in required_attributes: - self.assertIn(attribute, dir(SpectralShape)) + assert attribute in dir(SpectralShape) def test_required_methods(self): """Test the presence of required methods.""" @@ -1285,7 +1285,7 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(SpectralShape)) + assert method in dir(SpectralShape) def test_pickling(self): """ @@ -1296,7 +1296,7 @@ class can be pickled. shape = SpectralShape(360, 830, 1) data = pickle.dumps(shape) data = pickle.loads(data) # noqa: S301 - self.assertEqual(shape, data) + assert shape == data def test_start(self): """ @@ -1304,20 +1304,20 @@ def test_start(self): attribute. """ - self.assertEqual(SpectralShape(360, 830, 1).start, 360) + assert SpectralShape(360, 830, 1).start == 360 - self.assertRaises(AssertionError, lambda: SpectralShape(360, 360, 1)) + pytest.raises(AssertionError, lambda: SpectralShape(360, 360, 1)) - self.assertRaises(AssertionError, lambda: SpectralShape(360, 0, 1)) + pytest.raises(AssertionError, lambda: SpectralShape(360, 0, 1)) def test_end(self): """Test :attr:`colour.colorimetry.spectrum.SpectralShape.end` property.""" - self.assertEqual(SpectralShape(360, 830, 1).end, 830) + assert SpectralShape(360, 830, 1).end == 830 - self.assertRaises(AssertionError, lambda: SpectralShape(830, 830, 1)) + pytest.raises(AssertionError, lambda: SpectralShape(830, 830, 1)) - self.assertRaises(AssertionError, lambda: SpectralShape(830, 0, 1)) + pytest.raises(AssertionError, lambda: SpectralShape(830, 0, 1)) def test_interval(self): """ @@ -1325,7 +1325,7 @@ def test_interval(self): property. """ - self.assertEqual(SpectralShape(360, 830, 1).interval, 1) + assert SpectralShape(360, 830, 1).interval == 1 def test_boundaries(self): """ @@ -1336,8 +1336,8 @@ def test_boundaries(self): shape = SpectralShape(400, 700, 1) shape.boundaries = (360, 830) - self.assertEqual(shape.start, 360) - self.assertEqual(shape.end, 830) + assert shape.start == 360 + assert shape.end == 830 def test_wavelengths(self): """ @@ -1356,7 +1356,7 @@ def test__hash__(self): method. """ - self.assertIsInstance(hash(SpectralShape(0, 10, 0.1)), int) + assert isinstance(hash(SpectralShape(0, 10, 0.1)), int) def test__iter__(self): """ @@ -1375,13 +1375,13 @@ def test__contains__(self): method. """ - self.assertIn(360.1, SpectralShape(360, 830, 0.1)) + assert 360.1 in SpectralShape(360, 830, 0.1) - self.assertNotIn(360.11, SpectralShape(360, 830, 0.1)) + assert 360.11 not in SpectralShape(360, 830, 0.1) - self.assertIn(np.array([0.5, 0.6]), SpectralShape(0, 10, 0.1)) + assert np.array([0.5, 0.6]) in SpectralShape(0, 10, 0.1) - self.assertNotIn(np.array([0.5, 0.61]), SpectralShape(0, 10, 0.1)) + assert np.array([0.5, 0.61]) not in SpectralShape(0, 10, 0.1) def test__len__(self): """ @@ -1389,7 +1389,7 @@ def test__len__(self): method. """ - self.assertEqual(len(SpectralShape(0, 10, 0.1)), 101) + assert len(SpectralShape(0, 10, 0.1)) == 101 def test__eq__(self): """ @@ -1397,8 +1397,8 @@ def test__eq__(self): method. """ - self.assertEqual(SpectralShape(0, 10, 0.1), SpectralShape(0, 10, 0.1)) - self.assertNotEqual(SpectralShape(0, 10, 0.1), None) + assert SpectralShape(0, 10, 0.1) == SpectralShape(0, 10, 0.1) + assert SpectralShape(0, 10, 0.1) is not None def test__ne__(self): """ @@ -1406,7 +1406,7 @@ def test__ne__(self): method. """ - self.assertNotEqual(SpectralShape(0, 10, 0.1), SpectralShape(1, 10, 0.1)) + assert SpectralShape(0, 10, 0.1) != SpectralShape(1, 10, 0.1) def test_range(self): """Test :func:`colour.colorimetry.spectrum.SpectralShape.range` method.""" @@ -1417,13 +1417,13 @@ def test_range(self): ) -class TestSpectralDistribution(unittest.TestCase): +class TestSpectralDistribution: """ Define :class:`colour.colorimetry.spectrum.SpectralDistribution` class unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._sd = SpectralDistribution(DATA_SAMPLE, name="Sample") @@ -1447,7 +1447,7 @@ def test_required_attributes(self): ) for attribute in required_attributes: - self.assertIn(attribute, dir(SpectralDistribution)) + assert attribute in dir(SpectralDistribution) def test_required_methods(self): """Test the presence of required methods.""" @@ -1462,7 +1462,7 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(SpectralDistribution)) + assert method in dir(SpectralDistribution) def test_pickling(self): """ @@ -1472,7 +1472,7 @@ def test_pickling(self): data = pickle.dumps(self._sd) data = pickle.loads(data) # noqa: S301 - self.assertEqual(self._sd, data) + assert self._sd == data def test_display_name(self): """ @@ -1480,10 +1480,8 @@ def test_display_name(self): property. """ - self.assertEqual(self._sd.display_name, "Sample") - self.assertEqual( - self._non_uniform_sd.display_name, "Display Non Uniform Sample" - ) + assert self._sd.display_name == "Sample" + assert self._non_uniform_sd.display_name == "Display Non Uniform Sample" def test_wavelengths(self): """ @@ -1515,7 +1513,7 @@ def test_shape(self): property. """ - self.assertEqual(self._sd.shape, SpectralShape(340, 820, 20)) + assert self._sd.shape == SpectralShape(340, 820, 20) def test__init__(self): """ @@ -1543,7 +1541,7 @@ def test_interpolate(self): np.testing.assert_allclose( sd.values, DATA_SAMPLE_INTERPOLATED, atol=TOLERANCE_ABSOLUTE_TESTS ) - self.assertEqual(sd.shape, shape) + assert sd.shape == shape shape = SpectralShape( self._non_uniform_sd.shape.start, @@ -1556,13 +1554,10 @@ def test_interpolate(self): DATA_SAMPLE_INTERPOLATED_NON_UNIFORM, atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual( - sd.shape, - SpectralShape( - np.ceil(self._non_uniform_sd.shape.start), - np.floor(self._non_uniform_sd.shape.end), - 1, - ), + assert sd.shape == SpectralShape( + np.ceil(self._non_uniform_sd.shape.start), + np.floor(self._non_uniform_sd.shape.end), + 1, ) def test_extrapolate(self): @@ -1603,10 +1598,10 @@ def test_align(self): """ shape = SpectralShape(100, 900, 5) - self.assertEqual(self._sd.copy().align(shape).shape, shape) + assert self._sd.copy().align(shape).shape == shape shape = SpectralShape(600, 650, 1) - self.assertEqual(self._sd.copy().align(shape).shape, shape) + assert self._sd.copy().align(shape).shape == shape def test_trim(self): """ @@ -1615,10 +1610,10 @@ def test_trim(self): """ shape = SpectralShape(400, 700, 20) - self.assertEqual(self._sd.copy().trim(shape).shape, shape) + assert self._sd.copy().trim(shape).shape == shape shape = SpectralShape(200, 900, 1) - self.assertEqual(self._sd.copy().trim(shape).shape, self._sd.shape) + assert self._sd.copy().trim(shape).shape == self._sd.shape def test_normalise(self): """ @@ -1639,18 +1634,18 @@ def test_callback_on_domain_changed(self): """ sd = self._sd.copy() - self.assertEqual(sd.shape, SpectralShape(340, 820, 20)) + assert sd.shape == SpectralShape(340, 820, 20) sd[840] = 0 - self.assertEqual(sd.shape, SpectralShape(340, 840, 20)) + assert sd.shape == SpectralShape(340, 840, 20) -class TestMultiSpectralDistributions(unittest.TestCase): +class TestMultiSpectralDistributions: """ Define :class:`colour.colorimetry.spectrum.MultiSpectralDistributions` class unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._labels = ("x_bar", "y_bar", "z_bar") @@ -1702,7 +1697,7 @@ def test_required_attributes(self): ) for attribute in required_attributes: - self.assertIn(attribute, dir(MultiSpectralDistributions)) + assert attribute in dir(MultiSpectralDistributions) def test_required_methods(self): """Test the presence of required methods.""" @@ -1718,7 +1713,7 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(MultiSpectralDistributions)) + assert method in dir(MultiSpectralDistributions) def test_pickling(self): """ @@ -1728,7 +1723,7 @@ def test_pickling(self): data = pickle.dumps(self._msds) data = pickle.loads(data) # noqa: S301 - self.assertEqual(self._msds, data) + assert self._msds == data def test_display_name(self): """ @@ -1736,10 +1731,10 @@ def test_display_name(self): property. """ - self.assertEqual(self._sample_msds.display_name, "Sample Observer") - self.assertEqual( - self._non_uniform_sample_msds.display_name, - "Display Non Uniform Sample Observer", + assert self._sample_msds.display_name == "Sample Observer" + assert ( + self._non_uniform_sample_msds.display_name + == "Display Non Uniform Sample Observer" ) def test_wavelengths(self): @@ -1772,10 +1767,11 @@ def test_display_labels(self): display_labels` property. """ - self.assertTupleEqual(tuple(self._sample_msds.display_labels), self._labels) - self.assertEqual( - tuple(self._non_uniform_sample_msds.display_labels), - ("Display x_bar", "Display y_bar", "Display z_bar"), + assert tuple(self._sample_msds.display_labels) == self._labels + assert tuple(self._non_uniform_sample_msds.display_labels) == ( + "Display x_bar", + "Display y_bar", + "Display z_bar", ) def test_shape(self): @@ -1784,7 +1780,7 @@ def test_shape(self): property. """ - self.assertEqual(self._msds.shape, SpectralShape(380, 780, 5)) + assert self._msds.shape == SpectralShape(380, 780, 5) def test__init__(self): """ @@ -1817,7 +1813,7 @@ def test_interpolate(self): DATA_SAMPLE_INTERPOLATED, atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual(msds.shape, shape) + assert msds.shape == shape shape = SpectralShape( self._non_uniform_sample_msds.shape.start, @@ -1835,13 +1831,10 @@ def test_interpolate(self): DATA_SAMPLE_INTERPOLATED_NON_UNIFORM, atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual( - msds.shape, - SpectralShape( - np.ceil(self._non_uniform_sample_msds.shape.start), - np.floor(self._non_uniform_sample_msds.shape.end), - 1, - ), + assert msds.shape == SpectralShape( + np.ceil(self._non_uniform_sample_msds.shape.start), + np.floor(self._non_uniform_sample_msds.shape.end), + 1, ) def test_extrapolate(self): @@ -1890,10 +1883,10 @@ def test_align(self): msds = self._sample_msds.copy() shape = SpectralShape(100, 900, 5) - self.assertEqual(msds.align(shape).shape, shape) + assert msds.align(shape).shape == shape shape = SpectralShape(600, 650, 1) - self.assertEqual(msds.align(shape).shape, shape) + assert msds.align(shape).shape == shape def test_trim(self): """ @@ -1902,10 +1895,10 @@ def test_trim(self): """ shape = SpectralShape(400, 700, 5) - self.assertEqual(self._msds.copy().trim(shape).shape, shape) + assert self._msds.copy().trim(shape).shape == shape shape = SpectralShape(200, 900, 1) - self.assertEqual(self._msds.copy().trim(shape).shape, self._msds.shape) + assert self._msds.copy().trim(shape).shape == self._msds.shape def test_normalise(self): """ @@ -1926,11 +1919,11 @@ def test_to_sds(self): """ sds = self._non_uniform_sample_msds.to_sds() - self.assertEqual(len(sds), 3) + assert len(sds) == 3 for i, sd in enumerate(sds): - self.assertEqual(sd.name, self._labels[i]) - self.assertEqual(sd.display_name, self._display_labels[i]) + assert sd.name == self._labels[i] + assert sd.display_name == self._display_labels[i] def test_callback_on_domain_changed(self): """ @@ -1940,12 +1933,12 @@ def test_callback_on_domain_changed(self): """ msds = self._msds.copy() - self.assertEqual(msds.shape, SpectralShape(380, 780, 5)) + assert msds.shape == SpectralShape(380, 780, 5) msds[785] = 0 - self.assertEqual(msds.shape, SpectralShape(380, 785, 5)) + assert msds.shape == SpectralShape(380, 785, 5) -class TestReshapeSd(unittest.TestCase): +class TestReshapeSd: """ Define :func:`colour.colorimetry.spectrum.reshape_sd` definition unit tests methods. @@ -1956,8 +1949,8 @@ def test_reshape_sd(self): sd = SpectralDistribution(DATA_SAMPLE_ABRIDGED) sd_reshaped = reshape_sd(sd) - self.assertEqual(sd_reshaped, sd.copy().align(SPECTRAL_SHAPE_DEFAULT)) - self.assertEqual(reshape_sd(sd), sd_reshaped) + assert sd_reshaped == sd.copy().align(SPECTRAL_SHAPE_DEFAULT) + assert reshape_sd(sd) == sd_reshaped shape = colour.SpectralShape(100, 900, 1) extrapolator_kwargs = { @@ -1971,9 +1964,8 @@ def test_reshape_sd(self): method="Extrapolate", extrapolator_kwargs=extrapolator_kwargs, ) - self.assertEqual( - sd_reshaped, - sd.copy().extrapolate(shape, extrapolator_kwargs=extrapolator_kwargs), + assert sd_reshaped == sd.copy().extrapolate( + shape, extrapolator_kwargs=extrapolator_kwargs ) shape = colour.SpectralShape(400, 700, 1) @@ -1985,25 +1977,22 @@ def test_reshape_sd(self): interpolator=CubicSplineInterpolator, interpolator_kwargs=interpolator_kwargs, ) - self.assertEqual( - sd_reshaped, - sd.copy().interpolate( - shape, - interpolator=CubicSplineInterpolator, - interpolator_kwargs=interpolator_kwargs, - ), + assert sd_reshaped == sd.copy().interpolate( + shape, + interpolator=CubicSplineInterpolator, + interpolator_kwargs=interpolator_kwargs, ) sd = SpectralDistribution(DATA_SAMPLE) shape = colour.SpectralShape(500, 600, 1) sd_reshaped = reshape_sd(sd, shape, method="Trim") - self.assertEqual(sd_reshaped, sd.copy().trim(shape)) + assert sd_reshaped == sd.copy().trim(shape) if is_caching_enabled(): - self.assertIs(reshape_sd(sd, shape, method="Trim", copy=False), sd_reshaped) + assert reshape_sd(sd, shape, method="Trim", copy=False) is sd_reshaped -class TestSdsAndMdsToSds(unittest.TestCase): +class TestSdsAndMdsToSds: """ Define :func:`colour.colorimetry.spectrum.sds_and_msds_to_sds` definition unit tests methods. @@ -2020,8 +2009,8 @@ def test_sds_and_msds_to_sds(self): multi_sds_1 = MultiSpectralDistributions(DATA_MULTI_SAMPLE_ABRIDGED) multi_sds_2 = MultiSpectralDistributions(DATA_MULTI_SAMPLE_ABRIDGED) - self.assertEqual(sds_and_msds_to_sds(sd_1), [sd_1]) - self.assertEqual( + assert sds_and_msds_to_sds(sd_1) == [sd_1] + assert ( len( sds_and_msds_to_sds( [ @@ -2031,14 +2020,14 @@ def test_sds_and_msds_to_sds(self): multi_sds_2, ] ) - ), - 8, + ) + == 8 ) - self.assertEqual(len(sds_and_msds_to_sds(multi_sds_1)), 3) + assert len(sds_and_msds_to_sds(multi_sds_1)) == 3 -class TestSdsAndMsdsToMsds(unittest.TestCase): +class TestSdsAndMsdsToMsds: """ Define :func:`colour.colorimetry.spectrum.sds_and_msds_to_msds` definition unit tests methods. @@ -2055,18 +2044,17 @@ def test_sds_and_msds_to_msds(self): multi_sds_1 = MultiSpectralDistributions(DATA_MULTI_SAMPLE_ABRIDGED) multi_sds_2 = MultiSpectralDistributions(DATA_MULTI_SAMPLE_ABRIDGED) - self.assertEqual(len(sds_and_msds_to_msds(sd_1)), 6) + assert len(sds_and_msds_to_msds(sd_1)) == 6 - self.assertEqual(sds_and_msds_to_msds(multi_sds_1), multi_sds_1) + assert sds_and_msds_to_msds(multi_sds_1) == multi_sds_1 multi_sds_0 = sds_and_msds_to_msds([multi_sds_1]) np.testing.assert_array_equal(multi_sds_0.range, multi_sds_1.range) - self.assertEqual(sds_and_msds_to_msds([multi_sds_1]), multi_sds_1) + assert sds_and_msds_to_msds([multi_sds_1]) == multi_sds_1 shape = SpectralShape(500, 560, 10) - self.assertEqual( - sds_and_msds_to_msds([sd_1, sd_2, multi_sds_1, multi_sds_2]).shape, - shape, + assert ( + sds_and_msds_to_msds([sd_1, sd_2, multi_sds_1, multi_sds_2]).shape == shape ) np.testing.assert_allclose( @@ -2084,7 +2072,3 @@ def test_sds_and_msds_to_msds(self): ), atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/colorimetry/tests/test_transformations.py b/colour/colorimetry/tests/test_transformations.py index 29b88ea0c..4bd50667b 100644 --- a/colour/colorimetry/tests/test_transformations.py +++ b/colour/colorimetry/tests/test_transformations.py @@ -3,7 +3,6 @@ module. """ -import unittest import numpy as np @@ -34,7 +33,7 @@ ] -class TestRGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(unittest.TestCase): +class TestRGB_2_degree_cmfs_to_XYZ_2_degree_cmfs: """ Define :func:`colour.colorimetry.transformations.\ RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs` definition unit tests methods. @@ -105,7 +104,7 @@ def test_nan_RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(self): ) -class TestRGB_10_degree_cmfs_to_XYZ_10_degree_cmfs(unittest.TestCase): +class TestRGB_10_degree_cmfs_to_XYZ_10_degree_cmfs: """ Define :func:`colour.colorimetry.transformations.\ RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs` definition unit tests methods. @@ -182,7 +181,7 @@ def test_nan_RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs(self): ) -class TestRGB_10_degree_cmfs_to_LMS_10_degree_cmfs(unittest.TestCase): +class TestRGB_10_degree_cmfs_to_LMS_10_degree_cmfs: """ Define :func:`colour.colorimetry.transformations.\ RGB_10_degree_cmfs_to_LMS_10_degree_cmfs` definition unit tests methods. @@ -259,7 +258,7 @@ def test_nan_RGB_10_degree_cmfs_to_LMS_10_degree_cmfs(self): ) -class TestLMS_2_degree_cmfs_to_XYZ_2_degree_cmfs(unittest.TestCase): +class TestLMS_2_degree_cmfs_to_XYZ_2_degree_cmfs: """ Define :func:`colour.colorimetry.transformations.\ LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs` definition unit tests methods. @@ -336,7 +335,7 @@ def test_nan_LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs(self): ) -class TestLMS_10_degree_cmfs_to_XYZ_10_degree_cmfs(unittest.TestCase): +class TestLMS_10_degree_cmfs_to_XYZ_10_degree_cmfs: """ Define :func:`colour.colorimetry.transformations.\ LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs` definition unit tests methods. @@ -411,7 +410,3 @@ def test_nan_LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs(self): LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs( np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]) ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/colorimetry/tests/test_tristimulus_values.py b/colour/colorimetry/tests/test_tristimulus_values.py index a703b5872..0f618fc9e 100644 --- a/colour/colorimetry/tests/test_tristimulus_values.py +++ b/colour/colorimetry/tests/test_tristimulus_values.py @@ -11,9 +11,8 @@ from __future__ import annotations -import unittest - import numpy as np +import pytest from colour.algebra import LinearInterpolator, SpragueInterpolator from colour.colorimetry import ( @@ -577,7 +576,7 @@ ) -class TestHandleSpectralArguments(unittest.TestCase): +class TestHandleSpectralArguments: """ Define :func:`colour.colorimetry.tristimulus_values.\ handle_spectral_arguments` definition unit tests methods. @@ -590,32 +589,26 @@ def test_handle_spectral_arguments(self): """ cmfs, illuminant = handle_spectral_arguments() - self.assertEqual( - cmfs, - reshape_msds(MSDS_CMFS["CIE 1931 2 Degree Standard Observer"]), - ) - self.assertEqual(illuminant, reshape_sd(SDS_ILLUMINANTS["D65"])) + assert cmfs == reshape_msds(MSDS_CMFS["CIE 1931 2 Degree Standard Observer"]) + assert illuminant == reshape_sd(SDS_ILLUMINANTS["D65"]) shape = SpectralShape(400, 700, 20) cmfs, illuminant = handle_spectral_arguments(shape_default=shape) - self.assertEqual(cmfs.shape, shape) - self.assertEqual(illuminant.shape, shape) + assert cmfs.shape == shape + assert illuminant.shape == shape cmfs, illuminant = handle_spectral_arguments( cmfs_default="CIE 2015 2 Degree Standard Observer", illuminant_default="E", shape_default=shape, ) - self.assertEqual( - cmfs, - reshape_msds(MSDS_CMFS["CIE 2015 2 Degree Standard Observer"], shape=shape), - ) - self.assertEqual( - illuminant, sd_ones(shape, interpolator=LinearInterpolator) * 100 + assert cmfs == reshape_msds( + MSDS_CMFS["CIE 2015 2 Degree Standard Observer"], shape=shape ) + assert illuminant == sd_ones(shape, interpolator=LinearInterpolator) * 100 -class TestLagrangeCoefficientsASTME2022(unittest.TestCase): +class TestLagrangeCoefficientsASTME2022: """ Define :func:`colour.colorimetry.tristimulus_values.\ lagrange_coefficients_ASTME2022` definition unit tests methods. @@ -657,7 +650,7 @@ def test_lagrange_coefficients_ASTME2022(self): ) -class TestTristimulusWeightingFactorsASTME2022(unittest.TestCase): +class TestTristimulusWeightingFactorsASTME2022: """ Define :func:`colour.colorimetry.tristimulus_values.\ tristimulus_weighting_factors_ASTME2022` definition unit tests methods. @@ -746,7 +739,7 @@ def test_raise_exception_tristimulus_weighting_factors_ASTME2022(self): A_1 = sd_CIE_standard_illuminant_A(cmfs_1.shape) A_2 = sd_CIE_standard_illuminant_A(cmfs_2.shape) - self.assertRaises( + pytest.raises( ValueError, tristimulus_weighting_factors_ASTME2022, cmfs_1, @@ -754,7 +747,7 @@ def test_raise_exception_tristimulus_weighting_factors_ASTME2022(self): shape, ) - self.assertRaises( + pytest.raises( ValueError, tristimulus_weighting_factors_ASTME2022, cmfs_2, @@ -763,7 +756,7 @@ def test_raise_exception_tristimulus_weighting_factors_ASTME2022(self): ) -class TestAdjustTristimulusWeightingFactorsASTME308(unittest.TestCase): +class TestAdjustTristimulusWeightingFactorsASTME308: """ Define :func:`colour.colorimetry.tristimulus_values.\ adjust_tristimulus_weighting_factors_ASTME308` definition unit tests methods. @@ -786,7 +779,7 @@ def test_adjust_tristimulus_weighting_factors_ASTME308(self): ) -class TestSd_to_XYZ_integration(unittest.TestCase): +class TestSd_to_XYZ_integration: """ Define :func:`colour.colorimetry.tristimulus_values.sd_to_XYZ_integration` definition unit tests methods. @@ -865,7 +858,7 @@ def test_domain_range_scale_sd_to_XYZ_integration(self): ) -class TestSd_to_XYZ_tristimulus_weighting_factors_ASTME308(unittest.TestCase): +class TestSd_to_XYZ_tristimulus_weighting_factors_ASTME308: """ Define :func:`colour.colorimetry.tristimulus_values.\ sd_to_XYZ_tristimulus_weighting_factors_ASTME308` @@ -970,13 +963,13 @@ def test_domain_range_scale_sd_to_XYZ_twf_ASTME308(self): ) -class TestSd_to_XYZ_ASTME308(unittest.TestCase): +class TestSd_to_XYZ_ASTME308: """ Define :func:`colour.colorimetry.tristimulus_values.sd_to_XYZ_ASTME308` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._sd = SD_SAMPLE.copy() @@ -1336,20 +1329,20 @@ def test_raise_exception_sd_to_XYZ_ASTME308(self): definition raised exception. """ - self.assertRaises( + pytest.raises( ValueError, sd_to_XYZ_ASTME308, reshape_sd(self._sd, SpectralShape(360, 820, 2)), ) -class TestSd_to_XYZ(unittest.TestCase): +class TestSd_to_XYZ: """ Define :func:`colour.colorimetry.tristimulus_values.sd_to_XYZ` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._cmfs = MSDS_CMFS["CIE 1931 2 Degree Standard Observer"] @@ -1392,7 +1385,7 @@ def test_sd_to_XYZ(self): ) -class TestMsds_to_XYZ_integration(unittest.TestCase): +class TestMsds_to_XYZ_integration: """ Define :func:`colour.colorimetry.tristimulus_values.\ msds_to_XYZ_integration` definition unit tests methods. @@ -1456,7 +1449,7 @@ def test_domain_range_scale_msds_to_XYZ_integration(self): ) -class TestMsds_to_XYZ_ASTME308(unittest.TestCase): +class TestMsds_to_XYZ_ASTME308: """ Define :func:`colour.colorimetry.tristimulus_values.msds_to_XYZ_ASTME308` definition unit tests methods. @@ -1508,10 +1501,10 @@ def test_raise_exception_msds_to_XYZ_ASTME308(self): msds_to_XYZ_ASTME308` definition raise exception. """ - self.assertRaises(TypeError, msds_to_XYZ_ASTME308, DATA_TWO) + pytest.raises(TypeError, msds_to_XYZ_ASTME308, DATA_TWO) -class TestAbsoluteIntegrationToXYZ(unittest.TestCase): +class TestAbsoluteIntegrationToXYZ: """ Test the absolute integration to tristimulus values for :math:`k = 683` """ @@ -1612,7 +1605,7 @@ def test_absolute_integration_to_TVS_5nm(self): ) -class TestWavelength_to_XYZ(unittest.TestCase): +class TestWavelength_to_XYZ: """ Define :func:`colour.colorimetry.tristimulus_values.wavelength_to_XYZ` definition unit tests methods. @@ -1648,9 +1641,9 @@ def test_raise_exception_wavelength_to_XYZ(self): definition raised exception. """ - self.assertRaises(ValueError, wavelength_to_XYZ, 1) + pytest.raises(ValueError, wavelength_to_XYZ, 1) - self.assertRaises(ValueError, wavelength_to_XYZ, 1000) + pytest.raises(ValueError, wavelength_to_XYZ, 1000) def test_n_dimensional_wavelength_to_XYZ(self): """ @@ -1679,7 +1672,3 @@ def test_n_dimensional_wavelength_to_XYZ(self): np.testing.assert_allclose( wavelength_to_XYZ(wl, cmfs), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/colorimetry/tests/test_uniformity.py b/colour/colorimetry/tests/test_uniformity.py index 77637b6b8..1314b2fc1 100644 --- a/colour/colorimetry/tests/test_uniformity.py +++ b/colour/colorimetry/tests/test_uniformity.py @@ -3,8 +3,6 @@ from __future__ import annotations -import unittest - import numpy as np from colour.colorimetry import spectral_uniformity @@ -224,7 +222,7 @@ ) -class TestSpectralUniformity(unittest.TestCase): +class TestSpectralUniformity: """ Define :func:`colour.colorimetry.uniformity.spectral_uniformity` definition unit tests methods. @@ -249,7 +247,3 @@ def test_spectral_uniformity(self): DATA_UNIFORMITY_SECOND_ORDER_DERIVATIVES, atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/colorimetry/tests/test_whiteness.py b/colour/colorimetry/tests/test_whiteness.py index b282dc0fe..e03c0314b 100644 --- a/colour/colorimetry/tests/test_whiteness.py +++ b/colour/colorimetry/tests/test_whiteness.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.colorimetry.whiteness` module.""" -import unittest from itertools import product import numpy as np @@ -36,7 +35,7 @@ ] -class TestWhitenessBerger1959(unittest.TestCase): +class TestWhitenessBerger1959: """ Define :func:`colour.colorimetry.whiteness.whiteness_Berger1959` definition unit tests methods. @@ -130,7 +129,7 @@ def test_nan_whiteness_Berger1959(self): whiteness_Berger1959(cases, cases) -class TestWhitenessTaube1960(unittest.TestCase): +class TestWhitenessTaube1960: """ Define :func:`colour.colorimetry.whiteness.whiteness_Taube1960` definition unit tests methods. @@ -224,7 +223,7 @@ def test_nan_whiteness_Berger1959(self): whiteness_Berger1959(cases, cases) -class TestWhitenessStensby1968(unittest.TestCase): +class TestWhitenessStensby1968: """ Define :func:`colour.colorimetry.whiteness.whiteness_Stensby1968` definition unit tests methods. @@ -305,7 +304,7 @@ def test_nan_whiteness_Stensby1968(self): whiteness_Stensby1968(cases) -class TestWhitenessASTM313(unittest.TestCase): +class TestWhitenessASTM313: """ Define :func:`colour.colorimetry.whiteness.whiteness_ASTME313` definition unit tests methods. @@ -386,7 +385,7 @@ def test_nan_whiteness_ASTME313(self): whiteness_ASTME313(cases) -class TestWhitenessGanz1979(unittest.TestCase): +class TestWhitenessGanz1979: """ Define :func:`colour.colorimetry.whiteness.whiteness_Ganz1979` definition unit tests methods. @@ -475,7 +474,7 @@ def test_nan_whiteness_Ganz1979(self): whiteness_Ganz1979(cases[..., 0:2], cases[..., 0]) -class TestWhitenessCIE2004(unittest.TestCase): +class TestWhitenessCIE2004: """ Define :func:`colour.colorimetry.whiteness.whiteness_CIE2004` definition unit tests methods. @@ -574,7 +573,7 @@ def test_nan_whiteness_CIE2004(self): whiteness_CIE2004(cases[..., 0:2], cases[..., 0], cases[..., 0:2]) -class TestWhiteness(unittest.TestCase): +class TestWhiteness: """ Define :func:`colour.colorimetry.whiteness.whiteness` definition unit tests methods. @@ -608,7 +607,3 @@ def test_domain_range_scale_whiteness(self): value * factor, atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/colorimetry/tests/test_yellowness.py b/colour/colorimetry/tests/test_yellowness.py index 5db3632ac..53d8f5fae 100644 --- a/colour/colorimetry/tests/test_yellowness.py +++ b/colour/colorimetry/tests/test_yellowness.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.colorimetry.yellowness` module.""" -import unittest from itertools import product import numpy as np @@ -33,7 +32,7 @@ ] -class TestYellownessASTMD1925(unittest.TestCase): +class TestYellownessASTMD1925: """ Define :func:`colour.colorimetry.yellowness.yellowness_ASTMD1925` definition unit tests methods. @@ -114,7 +113,7 @@ def test_nan_yellowness_ASTMD1925(self): yellowness_ASTMD1925(cases) -class TestYellownessASTM313Alternative(unittest.TestCase): +class TestYellownessASTM313Alternative: """ Define :func:`colour.colorimetry.yellowness.\ yellowness_ASTME313_alternative` definition unit tests methods. @@ -205,7 +204,7 @@ def test_nan_yellowness_ASTME313_alternative(self): yellowness_ASTME313_alternative(cases) -class TestYellownessASTM313(unittest.TestCase): +class TestYellownessASTM313: """ Define :func:`colour.colorimetry.yellowness.yellowness_ASTME313` definition unit tests methods. @@ -297,7 +296,7 @@ def test_nan_yellowness_ASTME313(self): yellowness_ASTME313(cases) -class TestYellowness(unittest.TestCase): +class TestYellowness: """ Define :func:`colour.colorimetry.yellowness.yellowness` definition unit tests methods. @@ -323,7 +322,3 @@ def test_domain_range_scale_yellowness(self): value * factor, atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/continuous/tests/test_abstract.py b/colour/continuous/tests/test_abstract.py index 08d4e1f26..7d2ff132c 100644 --- a/colour/continuous/tests/test_abstract.py +++ b/colour/continuous/tests/test_abstract.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.continuous.abstract` module.""" -import unittest from colour.continuous import AbstractContinuousFunction @@ -17,7 +16,7 @@ ] -class TestAbstractContinuousFunction(unittest.TestCase): +class TestAbstractContinuousFunction: """ Define :class:`colour.continuous.abstract.AbstractContinuousFunction` class unit tests methods. @@ -38,7 +37,7 @@ def test_required_attributes(self): ) for attribute in required_attributes: - self.assertIn(attribute, dir(AbstractContinuousFunction)) + assert attribute in dir(AbstractContinuousFunction) def test_required_methods(self): """Test the presence of required methods.""" @@ -73,8 +72,4 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(AbstractContinuousFunction)) - - -if __name__ == "__main__": - unittest.main() + assert method in dir(AbstractContinuousFunction) diff --git a/colour/continuous/tests/test_multi_signal.py b/colour/continuous/tests/test_multi_signal.py index cc70b8590..e768b8de6 100644 --- a/colour/continuous/tests/test_multi_signal.py +++ b/colour/continuous/tests/test_multi_signal.py @@ -3,9 +3,9 @@ import pickle import textwrap -import unittest import numpy as np +import pytest from colour.algebra import ( CubicSplineInterpolator, @@ -34,13 +34,13 @@ ] -class TestMultiSignals(unittest.TestCase): +class TestMultiSignals: """ Define :class:`colour.continuous.multi_signals.MultiSignals` class unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._range_1 = np.linspace(10, 100, 10) @@ -68,7 +68,7 @@ def test_required_attributes(self): ) for attribute in required_attributes: - self.assertIn(attribute, dir(MultiSignals)) + assert attribute in dir(MultiSignals) def test_required_methods(self): """Test the presence of required methods.""" @@ -92,7 +92,7 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(MultiSignals)) + assert method in dir(MultiSignals) def test_pickling(self): """ @@ -102,7 +102,7 @@ def test_pickling(self): data = pickle.dumps(self._multi_signals) data = pickle.loads(data) # noqa: S301 - self.assertEqual(self._multi_signals, data) + assert self._multi_signals == data def test_dtype(self): """ @@ -110,11 +110,11 @@ def test_dtype(self): property. """ - self.assertEqual(self._multi_signals.dtype, DTYPE_FLOAT_DEFAULT) + assert self._multi_signals.dtype == DTYPE_FLOAT_DEFAULT multi_signals = self._multi_signals.copy() multi_signals.dtype = np.float32 - self.assertEqual(multi_signals.dtype, np.float32) + assert multi_signals.dtype == np.float32 def test_domain(self): """ @@ -148,7 +148,7 @@ def assert_warns(): multi_signals.domain = domain - self.assertWarns(ColourRuntimeWarning, assert_warns) + pytest.warns(ColourRuntimeWarning, assert_warns) def test_range(self): """ @@ -271,7 +271,7 @@ def test_extrapolator(self): property. """ - self.assertIsInstance(self._multi_signals.extrapolator(), Extrapolator) + assert isinstance(self._multi_signals.extrapolator(), Extrapolator) def test_extrapolator_kwargs(self): """ @@ -307,7 +307,7 @@ def test_raise_exception_function(self): function` property raised exception. """ - self.assertRaises((ValueError, TypeError), MultiSignals().function, 0) + pytest.raises((ValueError, TypeError), MultiSignals().function, 0) def test_signals(self): """ @@ -327,13 +327,13 @@ def test_labels(self): property. """ - self.assertListEqual(self._multi_signals.labels, ["0", "1", "2"]) + assert self._multi_signals.labels == ["0", "1", "2"] multi_signals = self._multi_signals.copy() multi_signals.labels = ["a", "b", "c"] - self.assertListEqual(multi_signals.labels, ["a", "b", "c"]) + assert multi_signals.labels == ["a", "b", "c"] def test_signal_type(self): """ @@ -343,7 +343,7 @@ def test_signal_type(self): multi_signals = MultiSignals(signal_type=Signal) - self.assertEqual(multi_signals.signal_type, Signal) + assert multi_signals.signal_type == Signal def test__init__(self): """ @@ -375,7 +375,7 @@ class NotSignal(Signal): """Not :class:`Signal` class.""" multi_signals = MultiSignals(self._range_1, signal_type=NotSignal) - self.assertIsInstance(multi_signals.signals["0"], NotSignal) + assert isinstance(multi_signals.signals["0"], NotSignal) np.testing.assert_array_equal(multi_signals.domain, self._domain_1) np.testing.assert_array_equal(multi_signals.range, self._range_1[:, None]) @@ -399,7 +399,7 @@ def test__hash__(self): method. """ - self.assertIsInstance(hash(self._multi_signals), int) + assert isinstance(hash(self._multi_signals), int) def test__str__(self): """ @@ -407,10 +407,11 @@ def test__str__(self): method. """ - self.assertEqual( - str(self._multi_signals), - textwrap.dedent( - """ + assert ( + str(self._multi_signals) + == ( + textwrap.dedent( + """ [[ 0. 10. 20. 30.] [ 1. 20. 30. 40.] [ 2. 30. 40. 50.] @@ -421,10 +422,11 @@ def test__str__(self): [ 7. 80. 90. 100.] [ 8. 90. 100. 110.] [ 9. 100. 110. 120.]]""" - )[1:], + )[1:] + ) ) - self.assertIsInstance(str(MultiSignals()), str) + assert isinstance(str(MultiSignals()), str) def test__repr__(self): """ @@ -432,8 +434,7 @@ def test__repr__(self): method. """ - self.assertEqual( - repr(self._multi_signals), + assert repr(self._multi_signals) == ( textwrap.dedent( """ MultiSignals([[ 0., 10., 20., 30.], @@ -452,10 +453,10 @@ def test__repr__(self): Extrapolator, {'method': 'Constant', 'left': nan, 'right': nan}) """ - ).strip(), + ).strip() ) - self.assertIsInstance(repr(MultiSignals()), str) + assert isinstance(repr(MultiSignals()), str) def test__getitem__(self): """ @@ -732,9 +733,9 @@ def test__contains__(self): method. """ - self.assertIn(0, self._multi_signals) - self.assertIn(0.5, self._multi_signals) - self.assertNotIn(1000, self._multi_signals) + assert 0 in self._multi_signals + assert 0.5 in self._multi_signals + assert 1000 not in self._multi_signals def test__iter__(self): """Test :func:`colour.continuous.signal.Signal.__iter__` method.""" @@ -750,7 +751,7 @@ def test__len__(self): method. """ - self.assertEqual(len(self._multi_signals), 10) + assert len(self._multi_signals) == 10 def test__eq__(self): """ @@ -761,9 +762,9 @@ def test__eq__(self): signal_1 = self._multi_signals.copy() signal_2 = self._multi_signals.copy() - self.assertEqual(signal_1, signal_2) + assert signal_1 == signal_2 - self.assertNotEqual(signal_1, None) + assert signal_1 is not None def test__ne__(self): """ @@ -775,41 +776,41 @@ def test__ne__(self): multi_signals_2 = self._multi_signals.copy() multi_signals_2[0] = 20 - self.assertNotEqual(multi_signals_1, multi_signals_2) + assert multi_signals_1 != multi_signals_2 multi_signals_2[0] = np.array([10, 20, 30]) - self.assertEqual(multi_signals_1, multi_signals_2) + assert multi_signals_1 == multi_signals_2 multi_signals_2.interpolator = CubicSplineInterpolator - self.assertNotEqual(multi_signals_1, multi_signals_2) + assert multi_signals_1 != multi_signals_2 multi_signals_2.interpolator = KernelInterpolator - self.assertEqual(multi_signals_1, multi_signals_2) + assert multi_signals_1 == multi_signals_2 multi_signals_2.interpolator_kwargs = {"window": 1} - self.assertNotEqual(multi_signals_1, multi_signals_2) + assert multi_signals_1 != multi_signals_2 multi_signals_2.interpolator_kwargs = {} - self.assertEqual(multi_signals_1, multi_signals_2) + assert multi_signals_1 == multi_signals_2 class NotExtrapolator(Extrapolator): """Not :class:`Extrapolator` class.""" multi_signals_2.extrapolator = NotExtrapolator - self.assertNotEqual(multi_signals_1, multi_signals_2) + assert multi_signals_1 != multi_signals_2 multi_signals_2.extrapolator = Extrapolator - self.assertEqual(multi_signals_1, multi_signals_2) + assert multi_signals_1 == multi_signals_2 multi_signals_2.extrapolator_kwargs = {} - self.assertNotEqual(multi_signals_1, multi_signals_2) + assert multi_signals_1 != multi_signals_2 multi_signals_2.extrapolator_kwargs = { "method": "Constant", "left": np.nan, "right": np.nan, } - self.assertEqual(multi_signals_1, multi_signals_2) + assert multi_signals_1 == multi_signals_2 def test_arithmetical_operation(self): """ @@ -928,17 +929,17 @@ def test_is_uniform(self): method. """ - self.assertTrue(self._multi_signals.is_uniform()) + assert self._multi_signals.is_uniform() multi_signals = self._multi_signals.copy() multi_signals[0.5] = 1.0 - self.assertFalse(multi_signals.is_uniform()) + assert not multi_signals.is_uniform() def test_copy(self): """Test :func:`colour.continuous.multi_signals.MultiSignals.copy` method.""" - self.assertIsNot(self._multi_signals, self._multi_signals.copy()) - self.assertEqual(self._multi_signals, self._multi_signals.copy()) + assert self._multi_signals is not self._multi_signals.copy() + assert self._multi_signals == self._multi_signals.copy() def test_multi_signals_unpack_data(self): """ @@ -947,12 +948,12 @@ def test_multi_signals_unpack_data(self): """ signals = MultiSignals.multi_signals_unpack_data(self._range_1) - self.assertListEqual(list(signals.keys()), ["0"]) + assert list(signals.keys()) == ["0"] np.testing.assert_array_equal(signals["0"].domain, self._domain_1) np.testing.assert_array_equal(signals["0"].range, self._range_1) signals = MultiSignals.multi_signals_unpack_data(self._range_1, self._domain_2) - self.assertListEqual(list(signals.keys()), ["0"]) + assert list(signals.keys()) == ["0"] np.testing.assert_array_equal(signals["0"].domain, self._domain_2) np.testing.assert_array_equal(signals["0"].range, self._range_1) @@ -962,7 +963,7 @@ def test_multi_signals_unpack_data(self): np.testing.assert_array_equal(signals["0"].domain, self._domain_2) signals = MultiSignals.multi_signals_unpack_data(self._range_2, self._domain_2) - self.assertListEqual(list(signals.keys()), ["0", "1", "2"]) + assert list(signals.keys()) == ["0", "1", "2"] np.testing.assert_array_equal(signals["0"].range, self._range_1) np.testing.assert_array_equal(signals["1"].range, self._range_1 + 10) np.testing.assert_array_equal(signals["2"].range, self._range_1 + 20) @@ -990,7 +991,7 @@ def test_multi_signals_unpack_data(self): signals = MultiSignals.multi_signals_unpack_data( dict(zip(self._domain_2, self._range_2)) ) - self.assertListEqual(list(signals.keys()), ["0", "1", "2"]) + assert list(signals.keys()) == ["0", "1", "2"] np.testing.assert_array_equal(signals["0"].range, self._range_1) np.testing.assert_array_equal(signals["1"].range, self._range_1 + 10) np.testing.assert_array_equal(signals["2"].range, self._range_1 + 20) @@ -1000,7 +1001,7 @@ def test_multi_signals_unpack_data(self): dict(zip(self._domain_2, self._range_2)) ) ) - self.assertListEqual(list(signals.keys()), ["0", "1", "2"]) + assert list(signals.keys()) == ["0", "1", "2"] np.testing.assert_array_equal(signals["0"].range, self._range_1) np.testing.assert_array_equal(signals["1"].range, self._range_1 + 10) np.testing.assert_array_equal(signals["2"].range, self._range_1 + 20) @@ -1008,7 +1009,7 @@ def test_multi_signals_unpack_data(self): signals = MultiSignals.multi_signals_unpack_data( dict(zip(self._domain_2, self._range_2)), labels=["0", "0", "0"] ) - self.assertListEqual(list(signals.keys()), ["0 - 0", "0 - 1", "0 - 2"]) + assert list(signals.keys()) == ["0 - 0", "0 - 1", "0 - 2"] if is_pandas_installed(): from pandas import DataFrame, Series @@ -1016,7 +1017,7 @@ def test_multi_signals_unpack_data(self): signals = MultiSignals.multi_signals_unpack_data( Series(dict(zip(self._domain_1, self._range_1))) ) - self.assertListEqual(list(signals.keys()), ["0"]) + assert list(signals.keys()) == ["0"] np.testing.assert_array_equal(signals["0"].domain, self._domain_1) np.testing.assert_array_equal(signals["0"].range, self._range_1) @@ -1024,7 +1025,7 @@ def test_multi_signals_unpack_data(self): signals = MultiSignals.multi_signals_unpack_data( DataFrame(data, self._domain_1) ) - self.assertListEqual(list(signals.keys()), ["a", "b", "c"]) + assert list(signals.keys()) == ["a", "b", "c"] np.testing.assert_array_equal(signals["a"].range, self._range_1) np.testing.assert_array_equal(signals["b"].range, self._range_1 + 10) np.testing.assert_array_equal(signals["c"].range, self._range_1 + 20) @@ -1113,7 +1114,3 @@ def test_to_dataframe(self): .to_dataframe() .equals(DataFrame(data, self._domain_2)) ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/continuous/tests/test_signal.py b/colour/continuous/tests/test_signal.py index 0d2db53ef..2cb4d7efa 100644 --- a/colour/continuous/tests/test_signal.py +++ b/colour/continuous/tests/test_signal.py @@ -3,9 +3,9 @@ import pickle import textwrap -import unittest import numpy as np +import pytest from colour.algebra import ( CubicSplineInterpolator, @@ -28,10 +28,10 @@ ] -class TestSignal(unittest.TestCase): +class TestSignal: """Define :class:`colour.continuous.signal.Signal` class unit tests methods.""" - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._range = np.linspace(10, 100, 10) @@ -54,7 +54,7 @@ def test_required_attributes(self): ) for attribute in required_attributes: - self.assertIn(attribute, dir(Signal)) + assert attribute in dir(Signal) def test_required_methods(self): """Test the presence of required methods.""" @@ -78,7 +78,7 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(Signal)) + assert method in dir(Signal) def test_pickling(self): """ @@ -88,16 +88,16 @@ def test_pickling(self): data = pickle.dumps(self._signal) data = pickle.loads(data) # noqa: S301 - self.assertEqual(self._signal, data) + assert self._signal == data def test_dtype(self): """Test :func:`colour.continuous.signal.Signal.dtype` property.""" - self.assertEqual(self._signal.dtype, DTYPE_FLOAT_DEFAULT) + assert self._signal.dtype == DTYPE_FLOAT_DEFAULT signal = self._signal.copy() signal.dtype = np.float32 - self.assertEqual(signal.dtype, np.float32) + assert signal.dtype == np.float32 def test_domain(self): """Test :func:`colour.continuous.signal.Signal.domain` property.""" @@ -128,7 +128,7 @@ def assert_warns(): signal.domain = domain - self.assertWarns(ColourRuntimeWarning, assert_warns) + pytest.warns(ColourRuntimeWarning, assert_warns) def test_range(self): """Test :func:`colour.continuous.signal.Signal.range` property.""" @@ -156,7 +156,7 @@ def assert_warns(): signal.range = self._range * np.inf - self.assertWarns(ColourRuntimeWarning, assert_warns) + pytest.warns(ColourRuntimeWarning, assert_warns) def test_interpolator(self): """Test :func:`colour.continuous.signal.Signal.interpolator` property.""" @@ -226,7 +226,7 @@ def test_interpolator_kwargs(self): def test_extrapolator(self): """Test :func:`colour.continuous.signal.Signal.extrapolator` property.""" - self.assertIsInstance(self._signal.extrapolator(), Extrapolator) + assert isinstance(self._signal.extrapolator(), Extrapolator) def test_extrapolator_kwargs(self): """ @@ -259,7 +259,7 @@ def test_raise_exception_function(self): exception. """ - self.assertRaises(ValueError, Signal().function, 0) + pytest.raises(ValueError, Signal().function, 0) def test__init__(self): """Test :func:`colour.continuous.signal.Signal.__init__` method.""" @@ -290,15 +290,16 @@ def test__init__(self): def test__hash__(self): """Test :func:`colour.continuous.signal.Signal.__hash__` method.""" - self.assertIsInstance(hash(self._signal), int) + assert isinstance(hash(self._signal), int) def test__str__(self): """Test :func:`colour.continuous.signal.Signal.__str__` method.""" - self.assertEqual( - str(self._signal), - textwrap.dedent( - """ + assert ( + str(self._signal) + == ( + textwrap.dedent( + """ [[ 0. 10.] [ 1. 20.] [ 2. 30.] @@ -309,16 +310,16 @@ def test__str__(self): [ 7. 80.] [ 8. 90.] [ 9. 100.]]""" - )[1:], + )[1:] + ) ) - self.assertIsInstance(str(Signal()), str) + assert isinstance(str(Signal()), str) def test__repr__(self): """Test :func:`colour.continuous.signal.Signal.__repr__` method.""" - self.assertEqual( - repr(self._signal), + assert repr(self._signal) == ( textwrap.dedent( """ Signal([[ 0., 10.], @@ -336,15 +337,15 @@ def test__repr__(self): Extrapolator, {'method': 'Constant', 'left': nan, 'right': nan}) """ - ).strip(), + ).strip() ) - self.assertIsInstance(repr(Signal()), str) + assert isinstance(repr(Signal()), str) def test__getitem__(self): """Test :func:`colour.continuous.signal.Signal.__getitem__` method.""" - self.assertEqual(self._signal[0], 10.0) + assert self._signal[0] == 10.0 np.testing.assert_allclose( self._signal[np.array([0, 1, 2])], @@ -480,9 +481,9 @@ def test__setitem__(self): def test__contains__(self): """Test :func:`colour.continuous.signal.Signal.__contains__` method.""" - self.assertIn(0, self._signal) - self.assertIn(0.5, self._signal) - self.assertNotIn(1000, self._signal) + assert 0 in self._signal + assert 0.5 in self._signal + assert 1000 not in self._signal def test__iter__(self): """Test :func:`colour.continuous.signal.Signal.__iter__` method.""" @@ -495,7 +496,7 @@ def test__iter__(self): def test__len__(self): """Test :func:`colour.continuous.signal.Signal.__len__` method.""" - self.assertEqual(len(self._signal), 10) + assert len(self._signal) == 10 def test__eq__(self): """Test :func:`colour.continuous.signal.Signal.__eq__` method.""" @@ -503,7 +504,7 @@ def test__eq__(self): signal_1 = self._signal.copy() signal_2 = self._signal.copy() - self.assertEqual(signal_1, signal_2) + assert signal_1 == signal_2 def test__ne__(self): """Test :func:`colour.continuous.signal.Signal.__ne__` method.""" @@ -512,41 +513,41 @@ def test__ne__(self): signal_2 = self._signal.copy() signal_2[0] = 20 - self.assertNotEqual(signal_1, signal_2) + assert signal_1 != signal_2 signal_2[0] = 10 - self.assertEqual(signal_1, signal_2) + assert signal_1 == signal_2 signal_2.interpolator = CubicSplineInterpolator - self.assertNotEqual(signal_1, signal_2) + assert signal_1 != signal_2 signal_2.interpolator = KernelInterpolator - self.assertEqual(signal_1, signal_2) + assert signal_1 == signal_2 signal_2.interpolator_kwargs = {"window": 1} - self.assertNotEqual(signal_1, signal_2) + assert signal_1 != signal_2 signal_2.interpolator_kwargs = {} - self.assertEqual(signal_1, signal_2) + assert signal_1 == signal_2 class NotExtrapolator(Extrapolator): """Not :class:`Extrapolator` class.""" signal_2.extrapolator = NotExtrapolator - self.assertNotEqual(signal_1, signal_2) + assert signal_1 != signal_2 signal_2.extrapolator = Extrapolator - self.assertEqual(signal_1, signal_2) + assert signal_1 == signal_2 signal_2.extrapolator_kwargs = {} - self.assertNotEqual(signal_1, signal_2) + assert signal_1 != signal_2 signal_2.extrapolator_kwargs = { "method": "Constant", "left": np.nan, "right": np.nan, } - self.assertEqual(signal_1, signal_2) + assert signal_1 == signal_2 def test_arithmetical_operation(self): """ @@ -663,17 +664,17 @@ def test_arithmetical_operation(self): def test_is_uniform(self): """Test :func:`colour.continuous.signal.Signal.is_uniform` method.""" - self.assertTrue(self._signal.is_uniform()) + assert self._signal.is_uniform() signal = self._signal.copy() signal[0.5] = 1.0 - self.assertFalse(signal.is_uniform()) + assert not signal.is_uniform() def test_copy(self): """Test :func:`colour.continuous.signal.Signal.copy` method.""" - self.assertIsNot(self._signal, self._signal.copy()) - self.assertEqual(self._signal, self._signal.copy()) + assert self._signal is not self._signal.copy() + assert self._signal == self._signal.copy() def test_signal_unpack_data(self): """ @@ -753,11 +754,7 @@ def test_to_series(self): if is_pandas_installed(): from pandas import Series - self.assertEqual( - Signal(self._range, self._domain).to_series().all(), - Series(dict(zip(self._domain, self._range))).all(), + assert ( + Signal(self._range, self._domain).to_series().all() + == Series(dict(zip(self._domain, self._range))).all() ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/contrast/tests/test_barten1999.py b/colour/contrast/tests/test_barten1999.py index 0ba7ca5c8..1124e7671 100644 --- a/colour/contrast/tests/test_barten1999.py +++ b/colour/contrast/tests/test_barten1999.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.contrast.barten1999` module.""" -import unittest from itertools import product import numpy as np @@ -34,7 +33,7 @@ ] -class TestOpticalMTFBarten1999(unittest.TestCase): +class TestOpticalMTFBarten1999: """ Define :func:`colour.contrast.barten1999.optical_MTF_Barten1999` definition unit tests methods. @@ -104,7 +103,7 @@ def test_nan_optical_MTF_Barten1999(self): optical_MTF_Barten1999(cases, cases) -class TestPupilDiameterBarten1999(unittest.TestCase): +class TestPupilDiameterBarten1999: """ Define :func:`colour.contrast.barten1999.pupil_diameter_Barten1999` definition unit tests methods. @@ -175,7 +174,7 @@ def test_nan_pupil_diameter_Barten1999(self): pupil_diameter_Barten1999(cases, cases, cases) -class TestSigmaBarten1999(unittest.TestCase): +class TestSigmaBarten1999: """ Define :func:`colour.contrast.barten1999.sigma_Barten1999` definition unit tests methods. @@ -249,7 +248,7 @@ def test_nan_sigma_Barten1999(self): sigma_Barten1999(cases, cases, cases) -class TestRetinalIlluminanceBarten1999(unittest.TestCase): +class TestRetinalIlluminanceBarten1999: """ Define :func:`colour.contrast.barten1999.retinal_illuminance_Barten1999` definition unit tests methods. @@ -319,7 +318,7 @@ def test_nan_retinal_illuminance_Barten1999(self): retinal_illuminance_Barten1999(cases, cases) -class TestMaximumAngularSizeBarten1999(unittest.TestCase): +class TestMaximumAngularSizeBarten1999: """ Define :func:`colour.contrast.barten1999.maximum_angular_size_Barten1999` definition unit tests methods. @@ -403,7 +402,7 @@ def test_nan_maximum_angular_size_Barten1999(self): maximum_angular_size_Barten1999(cases, cases, cases, cases) -class TestContrastSensitivityFunctionBarten1999(unittest.TestCase): +class TestContrastSensitivityFunctionBarten1999: """ Define :func:`colour.contrast.barten1999.\ contrast_sensitivity_function_Barten1999` definition unit tests methods. @@ -586,7 +585,3 @@ def test_nan_contrast_sensitivity_function_Barten1999(self): contrast_sensitivity_function_Barten1999( u=cases, sigma=cases, E=cases, X_0=cases ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/corresponding/tests/test_prediction.py b/colour/corresponding/tests/test_prediction.py index e46f9ff06..5764c65b6 100644 --- a/colour/corresponding/tests/test_prediction.py +++ b/colour/corresponding/tests/test_prediction.py @@ -3,8 +3,6 @@ from __future__ import annotations -import unittest - import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS @@ -219,7 +217,7 @@ ) -class TestConvertExperimentResultsBreneman1987(unittest.TestCase): +class TestConvertExperimentResultsBreneman1987: """ Define :func:`colour.corresponding.prediction.\ convert_experiment_results_Breneman1987` definition unit tests @@ -271,7 +269,7 @@ def test_convert_experiment_results_Breneman1987(self): ) -class TestCorrespondingChromaticitiesPredictionFairchild1990(unittest.TestCase): +class TestCorrespondingChromaticitiesPredictionFairchild1990: """ Define :func:`colour.corresponding.prediction.\ corresponding_chromaticities_prediction_Fairchild1990` definition unit tests @@ -296,7 +294,7 @@ def test_corresponding_chromaticities_prediction_Fairchild1990(self): ) -class TestCorrespondingChromaticitiesPredictionCIE1994(unittest.TestCase): +class TestCorrespondingChromaticitiesPredictionCIE1994: """ Define :func:`colour.corresponding.prediction.\ corresponding_chromaticities_prediction_CIE1994` definition unit tests methods. @@ -320,7 +318,7 @@ def test_corresponding_chromaticities_prediction_CIE1994(self): ) -class TestCorrespondingChromaticitiesPredictionCMCCAT2000(unittest.TestCase): +class TestCorrespondingChromaticitiesPredictionCMCCAT2000: """ Define :func:`colour.corresponding.prediction.\ corresponding_chromaticities_prediction_CMCCAT2000` definition unit tests @@ -345,7 +343,7 @@ def test_corresponding_chromaticities_prediction_CMCCAT2000(self): ) -class TestCorrespondingChromaticitiesPredictionVonKries(unittest.TestCase): +class TestCorrespondingChromaticitiesPredictionVonKries: """ Define :func:`colour.corresponding.prediction.\ corresponding_chromaticities_prediction_VonKries` definition unit tests @@ -370,7 +368,7 @@ def test_corresponding_chromaticities_prediction_VonKries(self): ) -class TestCorrespondingChromaticitiesPredictionZhai2018(unittest.TestCase): +class TestCorrespondingChromaticitiesPredictionZhai2018: """ Define :func:`colour.corresponding.prediction.\ corresponding_chromaticities_prediction_Zhai2018` definition unit tests diff --git a/colour/difference/tests/test__init__.py b/colour/difference/tests/test__init__.py index a5095bd5e..8c3227364 100644 --- a/colour/difference/tests/test__init__.py +++ b/colour/difference/tests/test__init__.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.difference` module.""" -import unittest import numpy as np @@ -21,7 +20,7 @@ ] -class TestDelta_E(unittest.TestCase): +class TestDelta_E: """Define :func:`colour.difference.delta_E` definition unit tests methods.""" def test_domain_range_scale_delta_E(self): @@ -45,7 +44,3 @@ def test_domain_range_scale_delta_E(self): value, atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/difference/tests/test_cam02_ucs.py b/colour/difference/tests/test_cam02_ucs.py index 9d432302b..594b60c8a 100644 --- a/colour/difference/tests/test_cam02_ucs.py +++ b/colour/difference/tests/test_cam02_ucs.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.difference.cam02_ucs` module.""" -import unittest from itertools import product import numpy as np @@ -28,7 +27,7 @@ ] -class TestDelta_E_Luo2006(unittest.TestCase): +class TestDelta_E_Luo2006: """ Define :func:`colour.difference.cam02_ucs.delta_E_Luo2006` definition unit tests methods. @@ -126,7 +125,3 @@ def test_nan_delta_E_Luo2006(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) delta_E_Luo2006(cases, cases, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"]) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/difference/tests/test_cam16_ucs.py b/colour/difference/tests/test_cam16_ucs.py index ee1c659e0..101a2d067 100644 --- a/colour/difference/tests/test_cam16_ucs.py +++ b/colour/difference/tests/test_cam16_ucs.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.difference.cam16_ucs` module.""" -import unittest from colour.difference.tests.test_cam02_ucs import TestDelta_E_Luo2006 @@ -28,7 +27,3 @@ class TestDelta_E_Li2017(TestDelta_E_Luo2006): of :func:`colour.difference.cam02_ucs.delta_E_Luo2006` and thus currently adopts the same unittests. """ - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/difference/tests/test_delta_e.py b/colour/difference/tests/test_delta_e.py index 3169c809d..99f97cc35 100644 --- a/colour/difference/tests/test_delta_e.py +++ b/colour/difference/tests/test_delta_e.py @@ -9,7 +9,6 @@ 30(1), 21-30. doi:10.1002/col.20070 """ -import unittest from itertools import product import numpy as np @@ -41,7 +40,7 @@ ] -class TestDelta_E_CIE1976(unittest.TestCase): +class TestDelta_E_CIE1976: """ Define :func:`colour.difference.delta_e.delta_E_CIE1976` definition unit tests methods. @@ -99,7 +98,7 @@ def test_nan_delta_E_CIE1976(self): """ -class TestDelta_E_CIE1994(unittest.TestCase): +class TestDelta_E_CIE1994: """ Define :func:`colour.difference.delta_e.delta_E_CIE1994` definition unit tests methods. @@ -224,7 +223,7 @@ def test_nan_delta_E_CIE1994(self): delta_E_CIE1994(cases, cases) -class TestDelta_E_CIE2000(unittest.TestCase): +class TestDelta_E_CIE2000: """ Define :func:`colour.difference.delta_e.delta_E_CIE2000` definition unit tests methods. @@ -516,7 +515,7 @@ def test_delta_E_CIE2000_Sharma2004(self): np.testing.assert_allclose(delta_E_CIE2000(Lab_1, Lab_2), d_E, atol=1e-4) -class TestDelta_E_CMC(unittest.TestCase): +class TestDelta_E_CMC: """ Define :func:`colour.difference.delta_e.delta_E_CMC` definition unit tests methods. @@ -637,7 +636,7 @@ def test_nan_delta_E_CMC(self): delta_E_CMC(cases, cases) -class TestDelta_E_ITP(unittest.TestCase): +class TestDelta_E_ITP: """ Define :func:`colour.difference.delta_e.delta_E_ITP` definition unit tests methods. @@ -746,7 +745,3 @@ def test_nan_delta_E_ITP(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) delta_E_ITP(cases, cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/difference/tests/test_din99.py b/colour/difference/tests/test_din99.py index f7f99385a..1f7cf658e 100644 --- a/colour/difference/tests/test_din99.py +++ b/colour/difference/tests/test_din99.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.difference.din99` module.""" -import unittest from itertools import product import numpy as np @@ -22,7 +21,7 @@ ] -class TestDelta_E_DIN99(unittest.TestCase): +class TestDelta_E_DIN99: """ Define :func:`colour.difference.din99.delta_E_DIN99` definition unit tests methods. @@ -141,7 +140,3 @@ def test_nan_delta_E_DIN99(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) delta_E_DIN99(cases, cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/difference/tests/test_huang2015.py b/colour/difference/tests/test_huang2015.py index 5dfa86cdc..fe99323cf 100644 --- a/colour/difference/tests/test_huang2015.py +++ b/colour/difference/tests/test_huang2015.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.difference.huang2015` module.""" -import unittest import numpy as np @@ -20,7 +19,7 @@ ] -class TestPowerFunctionHuang2015(unittest.TestCase): +class TestPowerFunctionHuang2015: """ Define :func:`colour.difference.huang2015.power_function_Huang2015` definition unit tests methods. @@ -39,7 +38,3 @@ def test_power_function_Huang2015(self): np.array([2.35748796, 2.98505036, 3.39651062]), atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/difference/tests/test_stress.py b/colour/difference/tests/test_stress.py index d3b887fac..b2f38a606 100644 --- a/colour/difference/tests/test_stress.py +++ b/colour/difference/tests/test_stress.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.difference.stress` module.""" -import unittest import numpy as np @@ -20,7 +19,7 @@ ] -class TestIndexStress(unittest.TestCase): +class TestIndexStress: """ Define :func:`colour.difference.stress.index_stress_Garcia2007` definition unit tests methods. @@ -40,7 +39,3 @@ def test_index_stress(self): 0.121170939369957, atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/geometry/tests/test_ellipse.py b/colour/geometry/tests/test_ellipse.py index b71bdccbc..a66088eb4 100644 --- a/colour/geometry/tests/test_ellipse.py +++ b/colour/geometry/tests/test_ellipse.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.geometry.ellipse` module.""" -import unittest import numpy as np @@ -28,7 +27,7 @@ ] -class TestEllipseCoefficientsCanonicalForm(unittest.TestCase): +class TestEllipseCoefficientsCanonicalForm: """ Define :func:`colour.geometry.ellipse.ellipse_coefficients_canonical_form` definition unit tests methods. @@ -57,7 +56,7 @@ def test_ellipse_coefficients_canonical_form(self): ) -class TestEllipseCoefficientsGeneralForm(unittest.TestCase): +class TestEllipseCoefficientsGeneralForm: """ Define :func:`colour.geometry.ellipse.ellipse_coefficients_general_form` definition unit tests methods. @@ -82,7 +81,7 @@ def test_ellipse_coefficients_general_form(self): ) -class TestPointAtAngleOnEllipse(unittest.TestCase): +class TestPointAtAngleOnEllipse: """ Define :func:`colour.geometry.ellipse.point_at_angle_on_ellipse` definition unit tests methods. @@ -124,7 +123,7 @@ def test_point_at_angle_on_ellipse(self): ) -class TestEllipseFittingHalir1998(unittest.TestCase): +class TestEllipseFittingHalir1998: """ Define :func:`colour.geometry.ellipse.ellipse_fitting_Halir1998` definition unit tests methods. @@ -150,7 +149,3 @@ def test_ellipse_fitting_Halir1998(self): ), atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/geometry/tests/test_intersection.py b/colour/geometry/tests/test_intersection.py index ab1761330..871c52131 100644 --- a/colour/geometry/tests/test_intersection.py +++ b/colour/geometry/tests/test_intersection.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.geometry.intersection` module.""" -import unittest import numpy as np @@ -24,7 +23,7 @@ ] -class TestExtendLineSegment(unittest.TestCase): +class TestExtendLineSegment: """ Define :func:`colour.geometry.intersection.extend_line_segment` definition unit tests methods. @@ -63,7 +62,7 @@ def test_extend_line_segment(self): ) -class TestIntersectLineSegments(unittest.TestCase): +class TestIntersectLineSegments: """ Define :func:`colour.geometry.intersection.intersect_line_segments` definition unit tests methods. @@ -127,7 +126,3 @@ def test_intersect_line_segments(self): s.coincident, np.array([[False, False, False, False], [False, False, False, True]]), ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/geometry/tests/test_primitives.py b/colour/geometry/tests/test_primitives.py index 10e50e45a..df384db0b 100644 --- a/colour/geometry/tests/test_primitives.py +++ b/colour/geometry/tests/test_primitives.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.geometry.primitives` module.""" -import unittest import numpy as np @@ -25,7 +24,7 @@ ] -class TestPrimitiveGrid(unittest.TestCase): +class TestPrimitiveGrid: """ Define :func:`colour.geometry.primitives.primitive_grid` definition unit tests methods. @@ -184,7 +183,7 @@ def test_primitive_grid(self): ) -class TestPrimitiveCube(unittest.TestCase): +class TestPrimitiveCube: """ Define :func:`colour.geometry.primitives.primitive_cube` definition unit tests methods. @@ -788,7 +787,3 @@ def test_primitive_cube(self): primitive_cube(planes=[MAPPING_PLANE_TO_AXIS[plane]])[0]["position"], atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/geometry/tests/test_section.py b/colour/geometry/tests/test_section.py index 14a387865..b3a65e552 100644 --- a/colour/geometry/tests/test_section.py +++ b/colour/geometry/tests/test_section.py @@ -1,9 +1,9 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.geometry.section` module.""" -import unittest import numpy as np +import pytest from colour.constants import TOLERANCE_ABSOLUTE_TESTS from colour.geometry import hull_section, primitive_cube @@ -29,7 +29,7 @@ ] -class TestEdgesToChord(unittest.TestCase): +class TestEdgesToChord: """ Define :func:`colour.geometry.section.edges_to_chord` definition unit tests methods. @@ -102,7 +102,7 @@ def test_edges_to_chord(self): ) -class TestCloseChord(unittest.TestCase): +class TestCloseChord: """ Define :func:`colour.geometry.section.close_chord` definition unit tests methods. @@ -118,7 +118,7 @@ def test_close_chord(self): ) -class TestUniqueVertices(unittest.TestCase): +class TestUniqueVertices: """ Define :func:`colour.geometry.section.unique_vertices` definition unit tests methods. @@ -145,7 +145,7 @@ def test_unique_vertices(self): ) -class TestHullSection(unittest.TestCase): +class TestHullSection: """ Define :func:`colour.geometry.section.hull_section` definition unit tests methods. @@ -235,8 +235,4 @@ def test_hull_section(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertRaises(ValueError, hull_section, hull, origin=-1) - - -if __name__ == "__main__": - unittest.main() + pytest.raises(ValueError, hull_section, hull, origin=-1) diff --git a/colour/geometry/tests/test_vertices.py b/colour/geometry/tests/test_vertices.py index 79973e6bd..916afb531 100644 --- a/colour/geometry/tests/test_vertices.py +++ b/colour/geometry/tests/test_vertices.py @@ -1,9 +1,9 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.geometry.vertices` module.""" -import unittest import numpy as np +import pytest from colour.constants import TOLERANCE_ABSOLUTE_TESTS from colour.geometry import ( @@ -29,7 +29,7 @@ ] -class TestPrimitiveVerticesQuadMpl(unittest.TestCase): +class TestPrimitiveVerticesQuadMpl: """ Define :func:`colour.geometry.vertices.primitive_vertices_quad_mpl` definition unit tests methods. @@ -104,12 +104,10 @@ def test_primitive_vertices_quad_mpl(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertRaises( - ValueError, lambda: primitive_vertices_quad_mpl(axis="Undefined") - ) + pytest.raises(ValueError, lambda: primitive_vertices_quad_mpl(axis="Undefined")) -class TestPrimitiveVerticesGridMpl(unittest.TestCase): +class TestPrimitiveVerticesGridMpl: """ Define :func:`colour.geometry.vertices.primitive_vertices_grid_mpl` definition unit tests methods. @@ -198,7 +196,7 @@ def test_primitive_vertices_grid_mpl(self): ) -class TestPrimitiveVerticesCubeMpl(unittest.TestCase): +class TestPrimitiveVerticesCubeMpl: """ Define :func:`colour.geometry.vertices.primitive_vertices_cube_mpl` definition unit tests methods. @@ -597,7 +595,7 @@ def test_primitive_vertices_cube_mpl(self): ) -class TestPrimitiveVerticesSphere(unittest.TestCase): +class TestPrimitiveVerticesSphere: """ Define :func:`colour.geometry.vertices.primitive_vertices_sphere` definition unit tests methods. @@ -996,10 +994,4 @@ def test_primitive_vertices_sphere(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertRaises( - ValueError, lambda: primitive_vertices_quad_mpl(axis="Undefined") - ) - - -if __name__ == "__main__": - unittest.main() + pytest.raises(ValueError, lambda: primitive_vertices_quad_mpl(axis="Undefined")) diff --git a/colour/graph/tests/test_conversion.py b/colour/graph/tests/test_conversion.py index 84f67f370..d085b83e0 100644 --- a/colour/graph/tests/test_conversion.py +++ b/colour/graph/tests/test_conversion.py @@ -1,9 +1,9 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.graph.conversion` module.""" -import unittest import numpy as np +import pytest from colour.characterisation import SDS_COLOURCHECKERS from colour.colorimetry import CCS_ILLUMINANTS, SDS_ILLUMINANTS @@ -24,7 +24,7 @@ ] -class TestDescribeConversionPath(unittest.TestCase): +class TestDescribeConversionPath: """ Define :func:`colour.graph.conversion.describe_conversion_path` definition unit tests methods. @@ -51,7 +51,7 @@ def test_describe_conversion_path(self): ) -class TestConvert(unittest.TestCase): +class TestConvert: """ Define :func:`colour.graph.conversion.convert` definition unit tests methods. @@ -147,7 +147,7 @@ def test_convert_direct_keyword_argument_passing(self): # Illuminant "ndarray" is converted to tuple here so that it can # be hashed by the "sd_to_XYZ" definition, this should never occur # in practical application. - self.assertRaises( + pytest.raises( AttributeError, lambda: convert( SDS_COLOURCHECKERS["ColorChecker N Ohta"]["dark skin"], @@ -156,7 +156,3 @@ def test_convert_direct_keyword_argument_passing(self): illuminant=tuple(illuminant), ), ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/io/luts/tests/test__init__.py b/colour/io/luts/tests/test__init__.py index 9c4a45197..8e0317bfc 100644 --- a/colour/io/luts/tests/test__init__.py +++ b/colour/io/luts/tests/test__init__.py @@ -6,9 +6,9 @@ import os import shutil import tempfile -import unittest import numpy as np +import pytest from colour.constants import TOLERANCE_ABSOLUTE_TESTS from colour.io import LUTSequence, read_LUT, write_LUT @@ -29,7 +29,7 @@ ROOT_LUTS: str = os.path.join(os.path.dirname(__file__), "resources") -class TestReadLUT(unittest.TestCase): +class TestReadLUT: """ Define :func:`colour.io.luts.__init__.read_LUT` definition unit tests methods. @@ -64,14 +64,14 @@ def test_read_LUT(self): ), atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual(LUT_1.name, "eotf sRGB 1D") - self.assertEqual(LUT_1.dimensions, 1) + assert LUT_1.name == "eotf sRGB 1D" + assert LUT_1.dimensions == 1 np.testing.assert_array_equal(LUT_1.domain, np.array([-0.1, 1.5])) - self.assertEqual(LUT_1.size, 16) - self.assertListEqual( - LUT_1.comments, - ['Generated by "Colour 0.3.11".', '"colour.models.eotf_sRGB".'], - ) + assert LUT_1.size == 16 + assert LUT_1.comments == [ + 'Generated by "Colour 0.3.11".', + '"colour.models.eotf_sRGB".', + ] LUT_2 = read_LUT(os.path.join(ROOT_LUTS, "resolve_cube", "LogC_Video.cube")) np.testing.assert_allclose( @@ -98,14 +98,13 @@ def test_read_LUT(self): ), atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual(LUT_2[1].size, 4) + assert LUT_2[1].size == 4 - self.assertEqual( - read_LUT(os.path.join(ROOT_LUTS, "sony_spi1d", "eotf_sRGB_1D.spi1d")), - read_LUT( - os.path.join(ROOT_LUTS, "sony_spi1d", "eotf_sRGB_1D.spi1d"), - method="Sony SPI1D", - ), + assert read_LUT( + os.path.join(ROOT_LUTS, "sony_spi1d", "eotf_sRGB_1D.spi1d") + ) == read_LUT( + os.path.join(ROOT_LUTS, "sony_spi1d", "eotf_sRGB_1D.spi1d"), + method="Sony SPI1D", ) def test_raise_exception_read_LUT(self): @@ -114,25 +113,25 @@ def test_raise_exception_read_LUT(self): exception. """ - self.assertRaises( + pytest.raises( ValueError, read_LUT, os.path.join(ROOT_LUTS, "sony_spi1d", "Exception_Raising.spi1d"), ) -class TestWriteLUT(unittest.TestCase): +class TestWriteLUT: """ Define :func:`colour.io.luts.__init__.write_LUT` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def tearDown(self): + def teardown_method(self): """After tests actions.""" shutil.rmtree(self._temporary_directory) @@ -151,14 +150,14 @@ def test_write_LUT(self): os.path.join(self._temporary_directory, "eotf_sRGB_1D.spi1d") ) - self.assertEqual(LUT_1_r, LUT_1_t) + assert LUT_1_r == LUT_1_t write_LUT( LUTSequence(LUT_1_r), os.path.join(self._temporary_directory, "eotf_sRGB_1D.spi1d"), ) - self.assertEqual(LUT_1_r, LUT_1_t) + assert LUT_1_r == LUT_1_t LUT_2_r = read_LUT( os.path.join( @@ -183,7 +182,7 @@ def test_write_LUT(self): ) ) - self.assertEqual(LUT_2_r, LUT_2_t) + assert LUT_2_r == LUT_2_t write_LUT( LUT_1_r, @@ -191,14 +190,9 @@ def test_write_LUT(self): method="Sony SPI1D", ) - self.assertEqual( - read_LUT(os.path.join(self._temporary_directory, "eotf_sRGB_1D.spi1d")), - read_LUT( - os.path.join(self._temporary_directory, "eotf_sRGB_1D"), - method="Sony SPI1D", - ), + assert read_LUT( + os.path.join(self._temporary_directory, "eotf_sRGB_1D.spi1d") + ) == read_LUT( + os.path.join(self._temporary_directory, "eotf_sRGB_1D"), + method="Sony SPI1D", ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/io/luts/tests/test_cinespace_csp.py b/colour/io/luts/tests/test_cinespace_csp.py index 6e04eb830..e8715177e 100644 --- a/colour/io/luts/tests/test_cinespace_csp.py +++ b/colour/io/luts/tests/test_cinespace_csp.py @@ -6,9 +6,9 @@ import os import shutil import tempfile -import unittest import numpy as np +import pytest from colour.constants import TOLERANCE_ABSOLUTE_TESTS from colour.io import LUT1D, LUT3x1D, read_LUT_Cinespace, write_LUT_Cinespace @@ -30,7 +30,7 @@ ROOT_LUTS: str = os.path.join(os.path.dirname(__file__), "resources", "cinespace") -class TestReadLUTCinespace(unittest.TestCase): +class TestReadLUTCinespace: """ Define :func:`colour.io.luts.cinespace_csp.read_LUT_Cinespace` definition unit tests methods. @@ -84,45 +84,45 @@ def test_read_LUT_Cinespace(self): ), atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual(LUT_1.name, "ACES Proxy 10 to ACES") - self.assertEqual(LUT_1.dimensions, 2) + assert LUT_1.name == "ACES Proxy 10 to ACES" + assert LUT_1.dimensions == 2 np.testing.assert_array_equal(LUT_1.domain, np.array([[0, 0, 0], [1, 1, 1]])) - self.assertEqual(LUT_1.size, 32) - self.assertListEqual(LUT_1.comments, []) + assert LUT_1.size == 32 + assert LUT_1.comments == [] LUT_2 = read_LUT_Cinespace(os.path.join(ROOT_LUTS, "Demo.csp")) - self.assertListEqual(LUT_2.comments, ["Comments are ignored by most parsers"]) + assert LUT_2.comments == ["Comments are ignored by most parsers"] np.testing.assert_array_equal(LUT_2.domain, np.array([[0, 0, 0], [1, 2, 3]])) LUT_3 = read_LUT_Cinespace( os.path.join(ROOT_LUTS, "Three_Dimensional_Table.csp") ) - self.assertEqual(LUT_3.dimensions, 3) - self.assertEqual(LUT_3.size, 2) + assert LUT_3.dimensions == 3 + assert LUT_3.size == 2 LUT_4 = read_LUT_Cinespace(os.path.join(ROOT_LUTS, "Explicit_Domain.csp")) - self.assertEqual(LUT_4[0].is_domain_explicit(), True) - self.assertEqual(LUT_4[1].table.shape, (2, 3, 4, 3)) + assert LUT_4[0].is_domain_explicit() is True + assert LUT_4[1].table.shape == (2, 3, 4, 3) LUT_5 = read_LUT_Cinespace( os.path.join(ROOT_LUTS, "Uncommon_3x1D_With_Pre_Lut.csp") ) - self.assertIsInstance(LUT_5[0], LUT3x1D) - self.assertIsInstance(LUT_5[1], LUT3x1D) + assert isinstance(LUT_5[0], LUT3x1D) + assert isinstance(LUT_5[1], LUT3x1D) -class TestWriteLUTCinespace(unittest.TestCase): +class TestWriteLUTCinespace: """ Define :func:`colour.io.luts.cinespace_csp.write_LUT_Cinespace` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def tearDown(self): + def teardown_method(self): """After tests actions.""" shutil.rmtree(self._temporary_directory) @@ -143,8 +143,8 @@ def test_write_LUT_Cinespace(self): LUT_1_t = read_LUT_Cinespace( os.path.join(self._temporary_directory, "ACES_Proxy_10_to_ACES.csp") ) - self.assertEqual(LUT_1_r, LUT_1_t) - self.assertEqual(LUT_1_r, LUT_1_t) + assert LUT_1_r == LUT_1_t + assert LUT_1_r == LUT_1_t LUT_2_r = read_LUT_Cinespace(os.path.join(ROOT_LUTS, "Demo.csp")) write_LUT_Cinespace( @@ -153,8 +153,8 @@ def test_write_LUT_Cinespace(self): LUT_2_t = read_LUT_Cinespace( os.path.join(self._temporary_directory, "Demo.csp") ) - self.assertEqual(LUT_2_r, LUT_2_t) - self.assertListEqual(LUT_2_r.comments, LUT_2_t.comments) + assert LUT_2_r == LUT_2_t + assert LUT_2_r.comments == LUT_2_t.comments LUT_3_r = read_LUT_Cinespace( os.path.join(ROOT_LUTS, "Three_Dimensional_Table.csp") @@ -166,7 +166,7 @@ def test_write_LUT_Cinespace(self): LUT_3_t = read_LUT_Cinespace( os.path.join(self._temporary_directory, "Three_Dimensional_Table.csp") ) - self.assertEqual(LUT_3_r, LUT_3_t) + assert LUT_3_r == LUT_3_t domain = tstack( ( @@ -206,7 +206,7 @@ def test_write_LUT_Cinespace(self): "Three_Dimensional_Table_With_Shaper.csp", ) ) - self.assertEqual(LUT_5_r, LUT_5_t) + assert LUT_5_r == LUT_5_t LUT_6_r = read_LUT_Cinespace( os.path.join(ROOT_LUTS, "Three_Dimensional_Table_With_Shaper.csp") @@ -230,7 +230,7 @@ def test_write_LUT_Cinespace(self): "Three_Dimensional_Table_With_Shaper.csp", ) ) - self.assertEqual(LUT_6_r, LUT_6_t) + assert LUT_6_r == LUT_6_t LUT_7_r = read_LUT_Cinespace( os.path.join(ROOT_LUTS, "ACES_Proxy_10_to_ACES.csp") @@ -242,7 +242,7 @@ def test_write_LUT_Cinespace(self): LUT_7_t = read_LUT_Cinespace( os.path.join(self._temporary_directory, "ACES_Proxy_10_to_ACES.csp") ) - self.assertEqual(LUT_7_r, LUT_7_t) + assert LUT_7_r == LUT_7_t def test_raise_exception_write_LUT_Cinespace(self): """ @@ -250,8 +250,4 @@ def test_raise_exception_write_LUT_Cinespace(self): definition raised exception. """ - self.assertRaises(TypeError, write_LUT_Cinespace, object(), "") - - -if __name__ == "__main__": - unittest.main() + pytest.raises(TypeError, write_LUT_Cinespace, object(), "") diff --git a/colour/io/luts/tests/test_common.py b/colour/io/luts/tests/test_common.py index 37a1c516a..aba890f25 100644 --- a/colour/io/luts/tests/test_common.py +++ b/colour/io/luts/tests/test_common.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.io.luts.common` module.""" -import unittest from colour.io.luts.common import path_to_title @@ -17,7 +16,7 @@ ] -class TestPathToTitle(unittest.TestCase): +class TestPathToTitle: """ Define :func:`colour.io.luts.common.path_to_title` definition unit tests methods. @@ -26,13 +25,7 @@ class TestPathToTitle(unittest.TestCase): def test_path_to_title(self): """Test :func:`colour.io.luts.common.path_to_title` definition.""" - self.assertEqual( - path_to_title( - "colour/io/luts/tests/resources/cinespace/RGB_1_0.5_0.25.csp" - ), - "RGB 1 0 5 0 25", + assert ( + path_to_title("colour/io/luts/tests/resources/cinespace/RGB_1_0.5_0.25.csp") + == "RGB 1 0 5 0 25" ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/io/luts/tests/test_iridas_cube.py b/colour/io/luts/tests/test_iridas_cube.py index 9ae6bea90..06bd1832f 100644 --- a/colour/io/luts/tests/test_iridas_cube.py +++ b/colour/io/luts/tests/test_iridas_cube.py @@ -6,7 +6,6 @@ import os import shutil import tempfile -import unittest import numpy as np @@ -34,7 +33,7 @@ ROOT_LUTS: str = os.path.join(os.path.dirname(__file__), "resources", "iridas_cube") -class TestReadLUTIridasCube(unittest.TestCase): +class TestReadLUTIridasCube: """ Define :func:`colour.io.luts.iridas_cube.read_LUT_IridasCube` definition unit tests methods. @@ -90,35 +89,35 @@ def test_read_LUT_IridasCube(self): ), atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual(LUT_1.name, "ACES Proxy 10 to ACES") - self.assertEqual(LUT_1.dimensions, 2) + assert LUT_1.name == "ACES Proxy 10 to ACES" + assert LUT_1.dimensions == 2 np.testing.assert_array_equal(LUT_1.domain, np.array([[0, 0, 0], [1, 1, 1]])) - self.assertEqual(LUT_1.size, 32) - self.assertListEqual(LUT_1.comments, []) + assert LUT_1.size == 32 + assert LUT_1.comments == [] LUT_2 = read_LUT_IridasCube(os.path.join(ROOT_LUTS, "Demo.cube")) - self.assertListEqual(LUT_2.comments, ["Comments can go anywhere"]) + assert LUT_2.comments == ["Comments can go anywhere"] np.testing.assert_array_equal(LUT_2.domain, np.array([[0, 0, 0], [1, 2, 3]])) LUT_3 = read_LUT_IridasCube( os.path.join(ROOT_LUTS, "Three_Dimensional_Table.cube") ) - self.assertEqual(LUT_3.dimensions, 3) - self.assertEqual(LUT_3.size, 2) + assert LUT_3.dimensions == 3 + assert LUT_3.size == 2 -class TestWriteLUTIridasCube(unittest.TestCase): +class TestWriteLUTIridasCube: """ Define :func:`colour.io.luts.iridas_cube.write_LUT_IridasCube` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def tearDown(self): + def teardown_method(self): """After tests actions.""" shutil.rmtree(self._temporary_directory) @@ -139,13 +138,13 @@ def test_write_LUT_IridasCube(self): LUT_1_t = read_LUT_IridasCube( os.path.join(self._temporary_directory, "ACES_Proxy_10_to_ACES.cube") ) - self.assertEqual(LUT_1_r, LUT_1_t) + assert LUT_1_r == LUT_1_t write_LUT_IridasCube( LUTSequence(LUT_1_r), os.path.join(self._temporary_directory, "ACES_Proxy_10_to_ACES.cube"), ) - self.assertEqual(LUT_1_r, LUT_1_t) + assert LUT_1_r == LUT_1_t LUT_2_r = read_LUT_IridasCube(os.path.join(ROOT_LUTS, "Demo.cube")) write_LUT_IridasCube( @@ -154,8 +153,8 @@ def test_write_LUT_IridasCube(self): LUT_2_t = read_LUT_IridasCube( os.path.join(self._temporary_directory, "Demo.cube") ) - self.assertEqual(LUT_2_r, LUT_2_t) - self.assertListEqual(LUT_2_r.comments, LUT_2_t.comments) + assert LUT_2_r == LUT_2_t + assert LUT_2_r.comments == LUT_2_t.comments LUT_3_r = read_LUT_IridasCube( os.path.join(ROOT_LUTS, "Three_Dimensional_Table.cube") @@ -167,7 +166,7 @@ def test_write_LUT_IridasCube(self): LUT_3_t = read_LUT_IridasCube( os.path.join(self._temporary_directory, "Three_Dimensional_Table.cube") ) - self.assertEqual(LUT_3_r, LUT_3_t) + assert LUT_3_r == LUT_3_t LUT_4_r = read_LUT_IridasCube( os.path.join(ROOT_LUTS, "ACES_Proxy_10_to_ACES.cube") @@ -179,8 +178,4 @@ def test_write_LUT_IridasCube(self): LUT_4_t = read_LUT_IridasCube( os.path.join(self._temporary_directory, "ACES_Proxy_10_to_ACES.cube") ) - self.assertEqual(LUT_4_r, LUT_4_t) - - -if __name__ == "__main__": - unittest.main() + assert LUT_4_r == LUT_4_t diff --git a/colour/io/luts/tests/test_lut.py b/colour/io/luts/tests/test_lut.py index f7d1bea40..dd6edaa76 100644 --- a/colour/io/luts/tests/test_lut.py +++ b/colour/io/luts/tests/test_lut.py @@ -5,9 +5,9 @@ import os import textwrap -import unittest import numpy as np +import pytest from colour.algebra import ( CubicSplineInterpolator, @@ -40,7 +40,7 @@ "ROOT_RESOURCES", "RANDOM_TRIPLETS", "TestAbstractLUT", - "AbstractLUTTest", + "MixinTestAbstractLUT", "TestLUT1D", "TestLUT3x1D", "TestLUT3D", @@ -54,7 +54,7 @@ ) -class TestAbstractLUT(unittest.TestCase): +class TestAbstractLUT: """Define :class:`colour.io.luts.lut.AbstractLUT` class unit tests methods.""" def test_required_attributes(self): @@ -70,7 +70,7 @@ def test_required_attributes(self): ) for attribute in required_attributes: - self.assertIn(attribute, dir(AbstractLUT)) + assert attribute in dir(AbstractLUT) def test_required_methods(self): """Test the presence of required methods.""" @@ -101,10 +101,10 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(AbstractLUT)) + assert method in dir(AbstractLUT) -class AbstractLUTTest(unittest.TestCase): +class MixinTestAbstractLUT: """ Define :class:`colour.io.luts.lut.LUT1D`, :class:`colour.io.luts.lut.LUT3x1D` and @@ -165,7 +165,7 @@ def test_required_methods(self): for class_ in (LUT1D, LUT3x1D, LUT3D): for method in required_methods: - self.assertIn(method, dir(class_)) + assert method in dir(class_) def test__init__(self): """ @@ -183,15 +183,14 @@ def test__init__(self): LUT.table, self._table_1, atol=TOLERANCE_ABSOLUTE_TESTS ) - self.assertEqual(str(id(LUT)), LUT.name) + assert str(id(LUT)) == LUT.name np.testing.assert_array_equal(LUT.domain, self._domain_1) - self.assertEqual(LUT.dimensions, self._dimensions) + assert LUT.dimensions == self._dimensions - self.assertIsInstance( - self._LUT_factory(self._table_3, domain=self._domain_3), - self._LUT_factory, + assert isinstance( + self._LUT_factory(self._table_3, domain=self._domain_3), self._LUT_factory ) def test_table(self): @@ -224,11 +223,11 @@ def test_name(self): LUT = self._LUT_factory(self._table_1) - self.assertEqual(LUT.name, str(id(LUT))) + assert LUT.name == str(id(LUT)) LUT = self._LUT_factory() - self.assertEqual(LUT.name, f"Unity {self._table_1.shape[0]}") + assert LUT.name == f"Unity {self._table_1.shape[0]}" def test_domain(self): """ @@ -260,7 +259,7 @@ def test_size(self): LUT = self._LUT_factory() - self.assertEqual(LUT.size, LUT.table.shape[0]) + assert LUT.size == LUT.table.shape[0] def test_dimensions(self): """ @@ -274,7 +273,7 @@ def test_dimensions(self): LUT = self._LUT_factory() - self.assertEqual(LUT.dimensions, self._dimensions) + assert LUT.dimensions == self._dimensions def test_comments(self): """ @@ -287,12 +286,12 @@ def test_comments(self): return LUT = self._LUT_factory() - self.assertListEqual(LUT.comments, []) + assert LUT.comments == [] comments = ["A first comment.", "A second comment."] LUT = self._LUT_factory(comments=comments) - self.assertListEqual(LUT.comments, comments) + assert LUT.comments == comments def test__str__(self): """ @@ -306,7 +305,7 @@ def test__str__(self): LUT = self._LUT_factory(name="Nemo") - self.assertEqual(str(LUT), self._str) + assert str(LUT) == self._str def test__repr__(self): """ @@ -329,7 +328,7 @@ def test__repr__(self): if self._dimensions == 3: return - self.assertEqual(repr(LUT), self._repr) + assert repr(LUT) == self._repr def test__eq__(self): """ @@ -344,7 +343,7 @@ def test__eq__(self): LUT_1 = self._LUT_factory() LUT_2 = self._LUT_factory() - self.assertEqual(LUT_1, LUT_2) + assert LUT_1 == LUT_2 def test__ne__(self): """ @@ -360,11 +359,11 @@ def test__ne__(self): LUT_2 = self._LUT_factory() LUT_2 += 0.1 - self.assertNotEqual(LUT_1, LUT_2) + assert LUT_1 != LUT_2 LUT_2 = self._LUT_factory() LUT_2.domain = self._domain_1 * 0.8 + 0.1 - self.assertNotEqual(LUT_1, LUT_2) + assert LUT_1 != LUT_2 def test_is_domain_explicit(self): """ @@ -376,11 +375,11 @@ def test_is_domain_explicit(self): if self._LUT_factory is None: return - self.assertFalse(self._LUT_factory().is_domain_explicit()) + assert not self._LUT_factory().is_domain_explicit() - self.assertTrue( - self._LUT_factory(self._table_3, domain=self._domain_3).is_domain_explicit() - ) + assert self._LUT_factory( + self._table_3, domain=self._domain_3 + ).is_domain_explicit() def test_arithmetical_operation(self): """ @@ -535,8 +534,8 @@ def test_copy(self): LUT_1 = self._LUT_factory() - self.assertIsNot(LUT_1, LUT_1.copy()) - self.assertEqual(LUT_1, LUT_1.copy()) + assert LUT_1 is not LUT_1.copy() + assert LUT_1.copy() == LUT_1 def test_invert(self): """ @@ -633,7 +632,7 @@ def test_apply(self): ) -class TestLUT1D(AbstractLUTTest): +class TestLUT1D(MixinTestAbstractLUT): """Define :class:`colour.io.luts.lut.LUT1D` class unit tests methods.""" def __init__(self, *args: Any) -> None: @@ -774,7 +773,7 @@ def __init__(self, *args: Any) -> None: self._applied_4 = self._inverted_apply_1 -class TestLUT3x1D(AbstractLUTTest): +class TestLUT3x1D(MixinTestAbstractLUT): """Define :class:`colour.io.luts.lut.LUT3x1D` class unit tests methods.""" def __init__(self, *args: Any) -> None: @@ -946,7 +945,7 @@ def __init__(self, *args: Any) -> None: self._applied_4 = self._inverted_apply_1 -class TestLUT3D(AbstractLUTTest): +class TestLUT3D(MixinTestAbstractLUT): """Define :class:`colour.io.luts.lut.LUT3D` class unit tests methods.""" def __init__(self, *args: Any) -> None: @@ -1145,13 +1144,13 @@ def __init__(self, *args: Any) -> None: self._applied_4 = self._inverted_apply_1 -class TestLUT_to_LUT(unittest.TestCase): +class TestLUT_to_LUT: """ Define :func:`colour.io.luts.lut.LUT_to_LUT` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._domain = np.array([[0.0, -0.1, -0.2], [1.0, 1.5, 3.0]]) @@ -1169,16 +1168,16 @@ def test_LUT_to_LUT(self): # "LUT" 1D to "LUT" 1D. LUT = LUT_to_LUT(self._LUT_1, LUT1D) - self.assertEqual(LUT, self._LUT_1) + assert LUT == self._LUT_1 # "LUT" 1D to "LUT" 3x1D. LUT = LUT_to_LUT(self._LUT_1, LUT3x1D) table = LUT1D.linear_table(16) ** (1 / 2.2) - self.assertEqual(LUT, LUT3x1D(tstack([table, table, table]))) + assert LUT3x1D(tstack([table, table, table])) == LUT # "LUT" 1D to "LUT" 3D. - self.assertRaises(ValueError, lambda: LUT_to_LUT(self._LUT_1, LUT3D)) + pytest.raises(ValueError, lambda: LUT_to_LUT(self._LUT_1, LUT3D)) LUT = LUT_to_LUT(self._LUT_1, LUT3D, force_conversion=True, size=5) @@ -1377,7 +1376,7 @@ def test_LUT_to_LUT(self): ) # "LUT" 3x1D to "LUT" 1D. - self.assertRaises(ValueError, lambda: LUT_to_LUT(self._LUT_2, LUT1D)) + pytest.raises(ValueError, lambda: LUT_to_LUT(self._LUT_2, LUT1D)) channel_weights = np.array([1.0, 0.0, 0.0]) LUT = LUT_to_LUT( @@ -1398,21 +1397,21 @@ def test_LUT_to_LUT(self): channel_weights=channel_weights, ) - self.assertEqual( - LUT, + assert ( LUT1D( np.sum(self._LUT_2.table * channel_weights, axis=-1), domain=domain, - ), + ) + == LUT ) # "LUT" 3x1D to "LUT" 3x1D. LUT = LUT_to_LUT(self._LUT_2, LUT3x1D) - self.assertEqual(LUT, self._LUT_2) + assert LUT == self._LUT_2 # "LUT" 3x1D to "LUT" 3D. - self.assertRaises(ValueError, lambda: LUT_to_LUT(self._LUT_2, LUT3D)) + pytest.raises(ValueError, lambda: LUT_to_LUT(self._LUT_2, LUT3D)) LUT = LUT_to_LUT(self._LUT_2, LUT3D, force_conversion=True, size=5) @@ -1611,7 +1610,7 @@ def test_LUT_to_LUT(self): ) # "LUT" 3D to "LUT" 1D. - self.assertRaises(ValueError, lambda: LUT_to_LUT(self._LUT_3, LUT1D)) + pytest.raises(ValueError, lambda: LUT_to_LUT(self._LUT_3, LUT1D)) channel_weights = np.array([1.0, 0.0, 0.0]) LUT = LUT_to_LUT( @@ -1682,7 +1681,7 @@ def test_LUT_to_LUT(self): ) # "LUT" 3D to "LUT" 3x1D. - self.assertRaises(ValueError, lambda: LUT_to_LUT(self._LUT_3, LUT3x1D)) + pytest.raises(ValueError, lambda: LUT_to_LUT(self._LUT_3, LUT3x1D)) LUT = LUT_to_LUT(self._LUT_3, LUT3x1D, force_conversion=True, size=16) @@ -1714,8 +1713,4 @@ def test_LUT_to_LUT(self): # "LUT" 3D to "LUT" 3D. LUT = LUT_to_LUT(self._LUT_3, LUT3D) - self.assertEqual(LUT, self._LUT_3) - - -if __name__ == "__main__": - unittest.main() + assert LUT == self._LUT_3 diff --git a/colour/io/luts/tests/test_operator.py b/colour/io/luts/tests/test_operator.py index 612693171..6770a4365 100644 --- a/colour/io/luts/tests/test_operator.py +++ b/colour/io/luts/tests/test_operator.py @@ -2,7 +2,6 @@ """Define the unit tests for the :mod:`colour.io.luts.operator` module.""" import textwrap -import unittest import numpy as np @@ -23,7 +22,7 @@ ] -class TestAbstractLUTSequenceOperator(unittest.TestCase): +class TestAbstractLUTSequenceOperator: """ Define :class:`colour.io.luts.operator.AbstractLUTSequenceOperator` class unit tests methods. @@ -35,7 +34,7 @@ def test_required_attributes(self): required_attributes = ("name", "comments") for method in required_attributes: - self.assertIn(method, dir(AbstractLUTSequenceOperator)) + assert method in dir(AbstractLUTSequenceOperator) def test_required_methods(self): """Test the presence of required methods.""" @@ -43,16 +42,16 @@ def test_required_methods(self): required_methods = ("apply",) for method in required_methods: - self.assertIn(method, dir(AbstractLUTSequenceOperator)) + assert method in dir(AbstractLUTSequenceOperator) -class TestLUTOperatorMatrix(unittest.TestCase): +class TestLUTOperatorMatrix: """ Define :class:`colour.io.luts.operator.LUTOperatorMatrix` class unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._lut_operator_matrix = LUTOperatorMatrix( @@ -68,7 +67,7 @@ def test_required_attributes(self): required_attributes = ("matrix", "offset") for method in required_attributes: - self.assertIn(method, dir(LUTOperatorMatrix)) + assert method in dir(LUTOperatorMatrix) def test_required_methods(self): """Test the presence of required methods.""" @@ -76,7 +75,7 @@ def test_required_methods(self): required_methods = ("__str__", "__repr__", "__eq__", "__ne__", "apply") for method in required_methods: - self.assertIn(method, dir(LUTOperatorMatrix)) + assert method in dir(LUTOperatorMatrix) def test_matrix(self): """ @@ -106,10 +105,11 @@ def test__str__(self): method. """ - self.assertEqual( - str(self._lut_operator_matrix), - textwrap.dedent( - """ + assert ( + str(self._lut_operator_matrix) + == ( + textwrap.dedent( + """ LUTOperatorMatrix - Nemo Matrix ------------------------------- @@ -121,7 +121,8 @@ def test__str__(self): A first comment. A second comment.""" - )[1:], + )[1:] + ) ) def test__repr__(self): @@ -130,8 +131,7 @@ def test__repr__(self): method. """ - self.assertEqual( - repr(self._lut_operator_matrix), + assert repr(self._lut_operator_matrix) == ( textwrap.dedent( """ LUTOperatorMatrix([[ 0. , 0.06666667, 0.13333333, 0.2 ], @@ -141,7 +141,7 @@ def test__repr__(self): [ 0.25, 0.5 , 0.75, 1. ], name='Nemo Matrix', comments=['A first comment.', 'A second comment.'])"""[1:] - ), + ) ) def test__eq__(self): @@ -152,7 +152,7 @@ def test__eq__(self): np.array([0.25, 0.5, 0.75, 1.0]), ) - self.assertEqual(self._lut_operator_matrix, matrix) + assert self._lut_operator_matrix == matrix def test__neq__(self): """ @@ -162,7 +162,7 @@ def test__neq__(self): matrix = LUTOperatorMatrix(np.reshape(np.linspace(0, 1, 16), (4, 4)) * 0.75) - self.assertNotEqual(self._lut_operator_matrix, matrix) + assert self._lut_operator_matrix != matrix def test_apply(self): """Test :class:`colour.io.luts.operator.LUTOperatorMatrix.apply` method.""" @@ -231,7 +231,3 @@ def test_apply(self): ), atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/io/luts/tests/test_resolve_cube.py b/colour/io/luts/tests/test_resolve_cube.py index bcd5c62f8..25b465368 100644 --- a/colour/io/luts/tests/test_resolve_cube.py +++ b/colour/io/luts/tests/test_resolve_cube.py @@ -6,9 +6,9 @@ import os import shutil import tempfile -import unittest import numpy as np +import pytest from colour.constants import TOLERANCE_ABSOLUTE_TESTS from colour.io import LUT1D, read_LUT_ResolveCube, write_LUT_ResolveCube @@ -29,7 +29,7 @@ ROOT_LUTS: str = os.path.join(os.path.dirname(__file__), "resources", "resolve_cube") -class TestReadLUTResolveCube(unittest.TestCase): +class TestReadLUTResolveCube: """ Define :func:`colour.io.luts.resolve_cube.read_LUT_ResolveCube` definition unit tests methods. @@ -85,21 +85,21 @@ def test_read_LUT_ResolveCube(self): ), atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual(LUT_1.name, "ACES Proxy 10 to ACES") - self.assertEqual(LUT_1.dimensions, 2) + assert LUT_1.name == "ACES Proxy 10 to ACES" + assert LUT_1.dimensions == 2 np.testing.assert_array_equal(LUT_1.domain, np.array([[0, 0, 0], [1, 1, 1]])) - self.assertEqual(LUT_1.size, 32) - self.assertListEqual(LUT_1.comments, []) + assert LUT_1.size == 32 + assert LUT_1.comments == [] LUT_2 = read_LUT_ResolveCube(os.path.join(ROOT_LUTS, "Demo.cube")) - self.assertListEqual(LUT_2.comments, ["Comments can't go anywhere"]) + assert LUT_2.comments == ["Comments can't go anywhere"] np.testing.assert_array_equal(LUT_2.domain, np.array([[0, 0, 0], [3, 3, 3]])) LUT_3 = read_LUT_ResolveCube( os.path.join(ROOT_LUTS, "Three_Dimensional_Table.cube") ) - self.assertEqual(LUT_3.dimensions, 3) - self.assertEqual(LUT_3.size, 2) + assert LUT_3.dimensions == 3 + assert LUT_3.size == 2 LUT_4 = read_LUT_ResolveCube(os.path.join(ROOT_LUTS, "LogC_Video.cube")) np.testing.assert_allclose( @@ -126,21 +126,21 @@ def test_read_LUT_ResolveCube(self): ), atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual(LUT_4[1].size, 4) + assert LUT_4[1].size == 4 -class TestWriteLUTResolveCube(unittest.TestCase): +class TestWriteLUTResolveCube: """ Define :func:`colour.io.luts.resolve_cube.write_LUT_ResolveCube` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def tearDown(self): + def teardown_method(self): """After tests actions.""" shutil.rmtree(self._temporary_directory) @@ -164,7 +164,7 @@ def test_write_LUT_ResolveCube(self): os.path.join(self._temporary_directory, "ACES_Proxy_10_to_ACES.cube") ) - self.assertEqual(LUT_1_r, LUT_1_t) + assert LUT_1_r == LUT_1_t LUT_2_r = read_LUT_ResolveCube(os.path.join(ROOT_LUTS, "Demo.cube")) @@ -176,8 +176,8 @@ def test_write_LUT_ResolveCube(self): os.path.join(self._temporary_directory, "Demo.cube") ) - self.assertEqual(LUT_2_r, LUT_2_t) - self.assertListEqual(LUT_2_r.comments, LUT_2_t.comments) + assert LUT_2_r == LUT_2_t + assert LUT_2_r.comments == LUT_2_t.comments LUT_3_r = read_LUT_ResolveCube( os.path.join(ROOT_LUTS, "Three_Dimensional_Table.cube") @@ -192,7 +192,7 @@ def test_write_LUT_ResolveCube(self): os.path.join(self._temporary_directory, "Three_Dimensional_Table.cube") ) - self.assertEqual(LUT_3_r, LUT_3_t) + assert LUT_3_r == LUT_3_t LUT_4_r = read_LUT_ResolveCube( os.path.join(ROOT_LUTS, "Three_Dimensional_Table_With_Shaper.cube") @@ -219,7 +219,7 @@ def test_write_LUT_ResolveCube(self): os.path.join(ROOT_LUTS, "Three_Dimensional_Table_With_Shaper.cube") ) - self.assertEqual(LUT_4_r, LUT_4_t) + assert LUT_4_r == LUT_4_t LUT_5_r = read_LUT_ResolveCube( os.path.join(ROOT_LUTS, "ACES_Proxy_10_to_ACES.cube") @@ -234,7 +234,7 @@ def test_write_LUT_ResolveCube(self): os.path.join(self._temporary_directory, "ACES_Proxy_10_to_ACES.cube") ) - self.assertEqual(LUT_5_r, LUT_5_t) + assert LUT_5_r == LUT_5_t def test_raise_exception_write_LUT_ResolveCube(self): """ @@ -242,8 +242,4 @@ def test_raise_exception_write_LUT_ResolveCube(self): definition raised exception. """ - self.assertRaises(TypeError, write_LUT_ResolveCube, object(), "") - - -if __name__ == "__main__": - unittest.main() + pytest.raises(TypeError, write_LUT_ResolveCube, object(), "") diff --git a/colour/io/luts/tests/test_sequence.py b/colour/io/luts/tests/test_sequence.py index a2982d09b..5d093ab2c 100644 --- a/colour/io/luts/tests/test_sequence.py +++ b/colour/io/luts/tests/test_sequence.py @@ -4,7 +4,6 @@ from __future__ import annotations import textwrap -import unittest import numpy as np @@ -32,13 +31,13 @@ ] -class TestLUTSequence(unittest.TestCase): +class TestLUTSequence: """ Define :class:`colour.io.luts.sequence.LUTSequence` class unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._LUT_1 = LUT1D(LUT1D.linear_table(16) + 0.125, "Nemo 1D") @@ -56,7 +55,7 @@ def test_required_attributes(self): required_attributes = ("sequence",) for attribute in required_attributes: - self.assertIn(attribute, dir(LUTSequence)) + assert attribute in dir(LUTSequence) def test_required_methods(self): """Test the presence of required methods.""" @@ -77,7 +76,7 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(LUTSequence)) + assert method in dir(LUTSequence) def test_sequence(self): """Test :class:`colour.io.luts.sequence.LUTSequence.sequence` property.""" @@ -85,22 +84,19 @@ def test_sequence(self): sequence = [self._LUT_1, self._LUT_2, self._LUT_3] LUT_sequence = LUTSequence() LUT_sequence.sequence = sequence - self.assertListEqual(self._LUT_sequence.sequence, sequence) + assert self._LUT_sequence.sequence == sequence def test__init__(self): """Test :class:`colour.io.luts.sequence.LUTSequence.__init__` method.""" - self.assertEqual( - LUTSequence(self._LUT_1, self._LUT_2, self._LUT_3), - self._LUT_sequence, - ) + assert LUTSequence(self._LUT_1, self._LUT_2, self._LUT_3) == self._LUT_sequence def test__getitem__(self): """Test :class:`colour.io.luts.sequence.LUTSequence.__getitem__` method.""" - self.assertEqual(self._LUT_sequence[0], self._LUT_1) - self.assertEqual(self._LUT_sequence[1], self._LUT_2) - self.assertEqual(self._LUT_sequence[2], self._LUT_3) + assert self._LUT_sequence[0] == self._LUT_1 + assert self._LUT_sequence[1] == self._LUT_2 + assert self._LUT_sequence[2] == self._LUT_3 def test__setitem__(self): """Test :class:`colour.io.luts.sequence.LUTSequence.__setitem__` method.""" @@ -110,9 +106,9 @@ def test__setitem__(self): LUT_sequence[1] = self._LUT_1 LUT_sequence[2] = self._LUT_2 - self.assertEqual(LUT_sequence[1], self._LUT_1) - self.assertEqual(LUT_sequence[2], self._LUT_2) - self.assertEqual(LUT_sequence[0], self._LUT_3) + assert LUT_sequence[1] == self._LUT_1 + assert LUT_sequence[2] == self._LUT_2 + assert LUT_sequence[0] == self._LUT_3 def test__delitem__(self): """Test :class:`colour.io.luts.sequence.LUTSequence.__delitem__` method.""" @@ -122,18 +118,17 @@ def test__delitem__(self): del LUT_sequence[0] del LUT_sequence[0] - self.assertEqual(LUT_sequence[0], self._LUT_3) + assert LUT_sequence[0] == self._LUT_3 def test__len__(self): """Test :class:`colour.io.luts.sequence.LUTSequence.__len__` method.""" - self.assertEqual(len(self._LUT_sequence), 3) + assert len(self._LUT_sequence) == 3 def test__str__(self): """Test :class:`colour.io.luts.sequence.LUTSequence.__str__` method.""" - self.assertEqual( - str(self._LUT_sequence), + assert str(self._LUT_sequence) == ( textwrap.dedent( """ LUT Sequence @@ -168,7 +163,7 @@ def test__str__(self): [ 1. 1. 1.]] Size : (16, 3) """ - ).strip(), + ).strip() ) def test__repr__(self): @@ -177,8 +172,7 @@ def test__repr__(self): LUT_sequence = self._LUT_sequence.copy() LUT_sequence[1].table = LUT3D.linear_table(5) - self.assertEqual( - repr(LUT_sequence), + assert repr(LUT_sequence) == ( textwrap.dedent( """ LUTSequence( @@ -364,7 +358,7 @@ def test__repr__(self): 16) ) """.strip() - ), + ) ) def test__eq__(self): @@ -373,18 +367,17 @@ def test__eq__(self): LUT_sequence_1 = LUTSequence(self._LUT_1, self._LUT_2, self._LUT_3) LUT_sequence_2 = LUTSequence(self._LUT_1, self._LUT_2) - self.assertEqual(self._LUT_sequence, LUT_sequence_1) + assert self._LUT_sequence == LUT_sequence_1 - self.assertNotEqual(self._LUT_sequence, self._LUT_sequence[0]) + assert self._LUT_sequence != self._LUT_sequence[0] - self.assertNotEqual(LUT_sequence_1, LUT_sequence_2) + assert LUT_sequence_1 != LUT_sequence_2 def test__neq__(self): """Test :class:`colour.io.luts.sequence.LUTSequence.__neq__` method.""" - self.assertNotEqual( - self._LUT_sequence, - LUTSequence(self._LUT_1, self._LUT_2.copy() * 0.75, self._LUT_3), + assert self._LUT_sequence != LUTSequence( + self._LUT_1, self._LUT_2.copy() * 0.75, self._LUT_3 ) def test_insert(self): @@ -394,14 +387,11 @@ def test_insert(self): LUT_sequence.insert(1, self._LUT_2.copy()) - self.assertEqual( - LUT_sequence, - LUTSequence( - self._LUT_1, - self._LUT_2, - self._LUT_2, - self._LUT_3, - ), + assert LUT_sequence == LUTSequence( + self._LUT_1, + self._LUT_2, + self._LUT_2, + self._LUT_3, ) def test_apply(self): @@ -466,7 +456,3 @@ def apply( ), atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/io/luts/tests/test_sony_spi1d.py b/colour/io/luts/tests/test_sony_spi1d.py index 37114dba3..11b819d09 100644 --- a/colour/io/luts/tests/test_sony_spi1d.py +++ b/colour/io/luts/tests/test_sony_spi1d.py @@ -6,7 +6,6 @@ import os import shutil import tempfile -import unittest import numpy as np @@ -29,7 +28,7 @@ ROOT_LUTS: str = os.path.join(os.path.dirname(__file__), "resources", "sony_spi1d") -class TestReadLUTSonySPI1D(unittest.TestCase): +class TestReadLUTSonySPI1D: """ Define :func:`colour.io.luts.sony_spi1d.read_LUT_SonySPI1D` definition unit tests methods. @@ -64,37 +63,37 @@ def test_read_LUT_SonySPI1D(self): ), atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual(LUT_1.name, "eotf sRGB 1D") - self.assertEqual(LUT_1.dimensions, 1) + assert LUT_1.name == "eotf sRGB 1D" + assert LUT_1.dimensions == 1 np.testing.assert_array_equal(LUT_1.domain, np.array([-0.1, 1.5])) - self.assertEqual(LUT_1.size, 16) - self.assertListEqual( - LUT_1.comments, - ['Generated by "Colour 0.3.11".', '"colour.models.eotf_sRGB".'], - ) + assert LUT_1.size == 16 + assert LUT_1.comments == [ + 'Generated by "Colour 0.3.11".', + '"colour.models.eotf_sRGB".', + ] LUT_2 = read_LUT_SonySPI1D(os.path.join(ROOT_LUTS, "eotf_sRGB_3x1D.spi1d")) - self.assertListEqual( - LUT_2.comments, - ['Generated by "Colour 0.3.11".', '"colour.models.eotf_sRGB".'], - ) + assert LUT_2.comments == [ + 'Generated by "Colour 0.3.11".', + '"colour.models.eotf_sRGB".', + ] np.testing.assert_array_equal( LUT_2.domain, np.array([[-0.1, -0.1, -0.1], [1.5, 1.5, 1.5]]) ) -class TestWriteLUTSonySPI1D(unittest.TestCase): +class TestWriteLUTSonySPI1D: """ Define :func:`colour.io.luts.sony_spi1d.write_LUT_SonySPI1D` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def tearDown(self): + def teardown_method(self): """After tests actions.""" shutil.rmtree(self._temporary_directory) @@ -110,7 +109,7 @@ def test_write_LUT_SonySPI1D(self): LUT_1_t = read_LUT_SonySPI1D( os.path.join(self._temporary_directory, "eotf_sRGB_1D.spi1d") ) - self.assertEqual(LUT_1_r, LUT_1_t) + assert LUT_1_r == LUT_1_t LUT_2_r = read_LUT_SonySPI1D(os.path.join(ROOT_LUTS, "eotf_sRGB_3x1D.spi1d")) write_LUT_SonySPI1D( @@ -120,9 +119,5 @@ def test_write_LUT_SonySPI1D(self): LUT_2_t = read_LUT_SonySPI1D( os.path.join(self._temporary_directory, "eotf_sRGB_3x1D.spi1d") ) - self.assertEqual(LUT_2_r, LUT_2_t) - self.assertListEqual(LUT_2_r.comments, LUT_2_t.comments) - - -if __name__ == "__main__": - unittest.main() + assert LUT_2_r == LUT_2_t + assert LUT_2_r.comments == LUT_2_t.comments diff --git a/colour/io/luts/tests/test_sony_spi3d.py b/colour/io/luts/tests/test_sony_spi3d.py index 4780f53aa..94369fb7f 100644 --- a/colour/io/luts/tests/test_sony_spi3d.py +++ b/colour/io/luts/tests/test_sony_spi3d.py @@ -6,7 +6,6 @@ import os import shutil import tempfile -import unittest import numpy as np @@ -35,7 +34,7 @@ ROOT_LUTS: str = os.path.join(os.path.dirname(__file__), "resources", "sony_spi3d") -class TestReadLUTSonySPI3D(unittest.TestCase): +class TestReadLUTSonySPI3D: """ Define :func:`colour.io.luts.sony_spi3d.read_LUT_SonySPI3D` definition unit tests methods. @@ -158,39 +157,35 @@ def test_read_LUT_SonySPI3D(self): ), atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual(LUT_1.name, "Colour Correct") - self.assertEqual(LUT_1.dimensions, 3) + assert LUT_1.name == "Colour Correct" + assert LUT_1.dimensions == 3 np.testing.assert_array_equal(LUT_1.domain, np.array([[0, 0, 0], [1, 1, 1]])) - self.assertEqual(LUT_1.size, 4) - self.assertListEqual( - LUT_1.comments, ["Adapted from a LUT generated by Foundry::LUT."] - ) + assert LUT_1.size == 4 + assert LUT_1.comments == ["Adapted from a LUT generated by Foundry::LUT."] LUT_2 = read_LUT_SonySPI3D( os.path.join(ROOT_LUTS, "Colour_Correct_Unordered.spi3d") ) - self.assertEqual(LUT_2, LUT_1) - self.assertEqual(LUT_2.name, "Colour Correct Unordered") - self.assertEqual(LUT_2.dimensions, 3) - self.assertEqual(LUT_2.size, 4) - self.assertListEqual( - LUT_2.comments, ["Adapted from a LUT generated by Foundry::LUT."] - ) + assert LUT_2 == LUT_1 + assert LUT_2.name == "Colour Correct Unordered" + assert LUT_2.dimensions == 3 + assert LUT_2.size == 4 + assert LUT_2.comments == ["Adapted from a LUT generated by Foundry::LUT."] -class TestWriteLUTSonySPI3D(unittest.TestCase): +class TestWriteLUTSonySPI3D: """ Define :func:`colour.io.luts.sony_spi3d.write_LUT_SonySPI3D` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def tearDown(self): + def teardown_method(self): """After tests actions.""" shutil.rmtree(self._temporary_directory) @@ -207,13 +202,13 @@ def test_write_LUT_SonySPI3D(self): LUT_t = read_LUT_SonySPI3D( os.path.join(self._temporary_directory, "Colour_Correct.spi3d") ) - self.assertEqual(LUT_r, LUT_t) + assert LUT_r == LUT_t write_LUT_SonySPI3D( LUTSequence(LUT_r), os.path.join(self._temporary_directory, "Colour_Correct.spi3d"), ) - self.assertEqual(LUT_r, LUT_t) + assert LUT_r == LUT_t # Test for proper indexes sequentiality. path = os.path.join(self._temporary_directory, "Size_10_Indexes.spi3d") @@ -434,7 +429,3 @@ def test_write_LUT_SonySPI3D(self): ] ), ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/io/luts/tests/test_sony_spimtx.py b/colour/io/luts/tests/test_sony_spimtx.py index 7f7993f37..a53cdada9 100644 --- a/colour/io/luts/tests/test_sony_spimtx.py +++ b/colour/io/luts/tests/test_sony_spimtx.py @@ -6,7 +6,6 @@ import os import shutil import tempfile -import unittest import numpy as np @@ -29,7 +28,7 @@ ROOT_LUTS: str = os.path.join(os.path.dirname(__file__), "resources", "sony_spimtx") -class TestReadLUTSonySPImtx(unittest.TestCase): +class TestReadLUTSonySPImtx: """ Define :func:`colour.io.luts.sony_spimtx.read_LUT_SonySPImtx` definition unit tests methods. @@ -60,7 +59,7 @@ def test_read_LUT_SonySPImtx(self): np.array([0.000000, 0.000000, 0.000000, 0.000000]), atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual(LUT_1.name, "dt") + assert LUT_1.name == "dt" LUT_2 = read_LUT_SonySPImtx(os.path.join(ROOT_LUTS, "p3_to_xyz16.spimtx")) np.testing.assert_allclose( @@ -80,7 +79,7 @@ def test_read_LUT_SonySPImtx(self): np.array([0.000000, 0.000000, 0.000000, 0.000000]), atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual(LUT_2.name, "p3 to xyz16") + assert LUT_2.name == "p3 to xyz16" LUT_3 = read_LUT_SonySPImtx(os.path.join(ROOT_LUTS, "Matrix_Offset.spimtx")) np.testing.assert_allclose( @@ -100,21 +99,21 @@ def test_read_LUT_SonySPImtx(self): np.array([0.0, 0.0, 1.0, 0.0]), atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual(LUT_3.name, "Matrix Offset") + assert LUT_3.name == "Matrix Offset" -class TestWriteLUTSonySPImtx(unittest.TestCase): +class TestWriteLUTSonySPImtx: """ Define :func:`colour.io.luts.sony_spimtx.write_LUT_SonySPImtx` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def tearDown(self): + def teardown_method(self): """After tests actions.""" shutil.rmtree(self._temporary_directory) @@ -132,7 +131,7 @@ def test_write_LUT_SonySPImtx(self): LUT_1_t = read_LUT_SonySPImtx( os.path.join(self._temporary_directory, "dt.spimtx") ) - self.assertEqual(LUT_1_r, LUT_1_t) + assert LUT_1_r == LUT_1_t LUT_2_r = read_LUT_SonySPImtx(os.path.join(ROOT_LUTS, "p3_to_xyz16.spimtx")) write_LUT_SonySPImtx( @@ -142,9 +141,5 @@ def test_write_LUT_SonySPImtx(self): LUT_2_t = read_LUT_SonySPImtx( os.path.join(self._temporary_directory, "p3_to_xyz16.spimtx") ) - self.assertEqual(LUT_2_r, LUT_2_t) - self.assertListEqual(LUT_2_r.comments, LUT_2_t.comments) - - -if __name__ == "__main__": - unittest.main() + assert LUT_2_r == LUT_2_t + assert LUT_2_r.comments == LUT_2_t.comments diff --git a/colour/io/tests/test_ctl.py b/colour/io/tests/test_ctl.py index 2ce69c95a..41a25f634 100644 --- a/colour/io/tests/test_ctl.py +++ b/colour/io/tests/test_ctl.py @@ -7,7 +7,6 @@ import shutil import tempfile import textwrap -import unittest import numpy as np @@ -42,15 +41,15 @@ # cross-platform. -class TestCtlRender(unittest.TestCase): +class TestCtlRender: """Define :func:`colour.io.ctl.ctl_render` definition unit tests methods.""" - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def tearDown(self): + def teardown_method(self): """After tests actions.""" shutil.rmtree(self._temporary_directory) @@ -119,7 +118,7 @@ def test_ctl_render(self): # pragma: no cover ) -class TestProcessImageCtl(unittest.TestCase): +class TestProcessImageCtl: """ Define :func:`colour.io.ctl.process_image_ctl` definition unit tests methods. @@ -197,7 +196,7 @@ def test_process_image_ctl(self): # pragma: no cover ) -class TestTemplateCtlTransformFloat(unittest.TestCase): +class TestTemplateCtlTransformFloat: """ Define :func:`colour.io.ctl.template_ctl_transform_float` definition unit tests methods. @@ -247,10 +246,10 @@ def test_template_ctl_transform_float(self): aOut = aIn; }"""[1:] ) - self.assertEqual(ctl_foo_bar_float, target) + assert ctl_foo_bar_float == target -class TestTemplateCtlTransformFloat3(unittest.TestCase): +class TestTemplateCtlTransformFloat3: """ Define :func:`colour.io.ctl.template_ctl_transform_float3` definition unit tests methods. @@ -332,8 +331,4 @@ def test_template_ctl_transform_float3(self): 1: ] ) - self.assertEqual(ctl_foo_bar_float3, target) - - -if __name__ == "__main__": - unittest.main() + assert ctl_foo_bar_float3 == target diff --git a/colour/io/tests/test_image.py b/colour/io/tests/test_image.py index 584492fce..2031a48f5 100644 --- a/colour/io/tests/test_image.py +++ b/colour/io/tests/test_image.py @@ -7,7 +7,6 @@ import platform import shutil import tempfile -import unittest import numpy as np @@ -45,7 +44,7 @@ ROOT_RESOURCES: str = os.path.join(os.path.dirname(__file__), "resources") -class TestConvertBitDepth(unittest.TestCase): +class TestConvertBitDepth: """ Define :func:`colour.io.image.convert_bit_depth` definition unit tests methods. @@ -55,10 +54,10 @@ def test_convert_bit_depth(self): """Test :func:`colour.io.image.convert_bit_depth` definition.""" a = np.around(np.linspace(0, 1, 10) * 255).astype("uint8") - self.assertIs(convert_bit_depth(a, "uint8").dtype, np.dtype("uint8")) + assert convert_bit_depth(a, "uint8").dtype is np.dtype("uint8") np.testing.assert_equal(convert_bit_depth(a, "uint8"), a) - self.assertIs(convert_bit_depth(a, "uint16").dtype, np.dtype("uint16")) + assert convert_bit_depth(a, "uint16").dtype is np.dtype("uint16") np.testing.assert_equal( convert_bit_depth(a, "uint16"), np.array( @@ -77,7 +76,7 @@ def test_convert_bit_depth(self): ), ) - self.assertIs(convert_bit_depth(a, "float16").dtype, np.dtype("float16")) + assert convert_bit_depth(a, "float16").dtype is np.dtype("float16") np.testing.assert_allclose( convert_bit_depth(a, "float16"), np.array( @@ -97,7 +96,7 @@ def test_convert_bit_depth(self): atol=5e-4, ) - self.assertIs(convert_bit_depth(a, "float32").dtype, np.dtype("float32")) + assert convert_bit_depth(a, "float32").dtype is np.dtype("float32") np.testing.assert_allclose( convert_bit_depth(a, "float32"), np.array( @@ -117,22 +116,22 @@ def test_convert_bit_depth(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertIs(convert_bit_depth(a, "float64").dtype, np.dtype("float64")) + assert convert_bit_depth(a, "float64").dtype is np.dtype("float64") if hasattr(np, "float128"): # pragma: no cover - self.assertIs(convert_bit_depth(a, "float128").dtype, np.dtype("float128")) + assert convert_bit_depth(a, "float128").dtype is np.dtype("float128") a = np.around(np.linspace(0, 1, 10) * 65535).astype("uint16") - self.assertIs(convert_bit_depth(a, "uint8").dtype, np.dtype("uint8")) + assert convert_bit_depth(a, "uint8").dtype is np.dtype("uint8") np.testing.assert_equal( convert_bit_depth(a, "uint8"), np.array([0, 28, 56, 85, 113, 141, 170, 198, 226, 255]), ) - self.assertIs(convert_bit_depth(a, "uint16").dtype, np.dtype("uint16")) + assert convert_bit_depth(a, "uint16").dtype is np.dtype("uint16") np.testing.assert_equal(convert_bit_depth(a, "uint16"), a) - self.assertIs(convert_bit_depth(a, "float16").dtype, np.dtype("float16")) + assert convert_bit_depth(a, "float16").dtype is np.dtype("float16") np.testing.assert_allclose( convert_bit_depth(a, "float16"), np.array( @@ -152,7 +151,7 @@ def test_convert_bit_depth(self): atol=5e-2, ) - self.assertIs(convert_bit_depth(a, "float32").dtype, np.dtype("float32")) + assert convert_bit_depth(a, "float32").dtype is np.dtype("float32") np.testing.assert_allclose( convert_bit_depth(a, "float32"), np.array( @@ -172,19 +171,19 @@ def test_convert_bit_depth(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertIs(convert_bit_depth(a, "float64").dtype, np.dtype("float64")) + assert convert_bit_depth(a, "float64").dtype is np.dtype("float64") if hasattr(np, "float128"): # pragma: no cover - self.assertIs(convert_bit_depth(a, "float128").dtype, np.dtype("float128")) + assert convert_bit_depth(a, "float128").dtype is np.dtype("float128") a = np.linspace(0, 1, 10, dtype=np.float64) - self.assertIs(convert_bit_depth(a, "uint8").dtype, np.dtype("uint8")) + assert convert_bit_depth(a, "uint8").dtype is np.dtype("uint8") np.testing.assert_equal( convert_bit_depth(a, "uint8"), np.array([0, 28, 57, 85, 113, 142, 170, 198, 227, 255]), ) - self.assertIs(convert_bit_depth(a, "uint16").dtype, np.dtype("uint16")) + assert convert_bit_depth(a, "uint16").dtype is np.dtype("uint16") np.testing.assert_equal( convert_bit_depth(a, "uint16"), np.array( @@ -203,7 +202,7 @@ def test_convert_bit_depth(self): ), ) - self.assertIs(convert_bit_depth(a, "float16").dtype, np.dtype("float16")) + assert convert_bit_depth(a, "float16").dtype is np.dtype("float16") np.testing.assert_allclose( convert_bit_depth(a, "float16"), np.array( @@ -223,18 +222,18 @@ def test_convert_bit_depth(self): atol=5e-4, ) - self.assertIs(convert_bit_depth(a, "float32").dtype, np.dtype("float32")) + assert convert_bit_depth(a, "float32").dtype is np.dtype("float32") np.testing.assert_allclose( convert_bit_depth(a, "float32"), a, atol=TOLERANCE_ABSOLUTE_TESTS ) - self.assertIs(convert_bit_depth(a, "float64").dtype, np.dtype("float64")) + assert convert_bit_depth(a, "float64").dtype is np.dtype("float64") if hasattr(np, "float128"): # pragma: no cover - self.assertIs(convert_bit_depth(a, "float128").dtype, np.dtype("float128")) + assert convert_bit_depth(a, "float128").dtype is np.dtype("float128") -class TestReadImageOpenImageIO(unittest.TestCase): +class TestReadImageOpenImageIO: """ Define :func:`colour.io.image.read_image_OpenImageIO` definition unit tests methods. @@ -249,43 +248,43 @@ def test_read_image_OpenImageIO(self): # pragma: no cover image = read_image_OpenImageIO( os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr") ) - self.assertTupleEqual(image.shape, (1267, 1274, 3)) - self.assertIs(image.dtype, np.dtype("float32")) + assert image.shape == (1267, 1274, 3) + assert image.dtype is np.dtype("float32") image = read_image_OpenImageIO( os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr"), "float16", ) - self.assertIs(image.dtype, np.dtype("float16")) + assert image.dtype is np.dtype("float16") image, attributes = read_image_OpenImageIO( os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr"), attributes=True, ) - self.assertTupleEqual(image.shape, (1267, 1274, 3)) - self.assertEqual(attributes[0].name, "oiio:ColorSpace") - self.assertEqual(attributes[0].value, "Linear") + assert image.shape == (1267, 1274, 3) + assert attributes[0].name == "oiio:ColorSpace" + assert attributes[0].value == "Linear" image = read_image_OpenImageIO( os.path.join(ROOT_RESOURCES, "Single_Channel.exr") ) - self.assertTupleEqual(image.shape, (256, 256)) + assert image.shape == (256, 256) image = read_image_OpenImageIO( os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), "uint8" ) - self.assertTupleEqual(image.shape, (128, 256, 4)) - self.assertIs(image.dtype, np.dtype("uint8")) - self.assertEqual(np.min(image), 0) - self.assertEqual(np.max(image), 255) + assert image.shape == (128, 256, 4) + assert image.dtype is np.dtype("uint8") + assert np.min(image) == 0 + assert np.max(image) == 255 image = read_image_OpenImageIO( os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), "uint16" ) - self.assertTupleEqual(image.shape, (128, 256, 4)) - self.assertIs(image.dtype, np.dtype("uint16")) - self.assertEqual(np.min(image), 0) - self.assertEqual(np.max(image), 65535) + assert image.shape == (128, 256, 4) + assert image.dtype is np.dtype("uint16") + assert np.min(image) == 0 + assert np.max(image) == 65535 # TODO: Investigate "OIIO" behaviour here: 1.0 != 15360.0 # image = read_image_OpenImageIO( @@ -297,23 +296,23 @@ def test_read_image_OpenImageIO(self): # pragma: no cover image = read_image_OpenImageIO( os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), "float32" ) - self.assertIs(image.dtype, np.dtype("float32")) - self.assertEqual(np.min(image), 0.0) - self.assertEqual(np.max(image), 1.0) + assert image.dtype is np.dtype("float32") + assert np.min(image) == 0.0 + assert np.max(image) == 1.0 -class TestWriteImageOpenImageIO(unittest.TestCase): +class TestWriteImageOpenImageIO: """ Define :func:`colour.io.image.write_image_OpenImageIO` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def tearDown(self): + def teardown_method(self): """After tests actions.""" shutil.rmtree(self._temporary_directory) @@ -354,8 +353,8 @@ def test_write_image_OpenImageIO(self): # pragma: no cover image = read_image_OpenImageIO(source_image_path) write_image_OpenImageIO(image, target_image_path) image = read_image_OpenImageIO(target_image_path) - self.assertTupleEqual(image.shape, (1267, 1274, 3)) - self.assertIs(image.dtype, np.dtype("float32")) + assert image.shape == (1267, 1274, 3) + assert image.dtype is np.dtype("float32") chromaticities = ( 0.73470, @@ -390,7 +389,7 @@ def test_write_image_OpenImageIO(self): # pragma: no cover atol=TOLERANCE_ABSOLUTE_TESTS, ) else: - self.assertEqual(write_attribute.value, read_attribute.value) + assert write_attribute.value == read_attribute.value attest( attribute_exists, @@ -398,7 +397,7 @@ def test_write_image_OpenImageIO(self): # pragma: no cover ) -class TestReadImageImageio(unittest.TestCase): +class TestReadImageImageio: """ Define :func:`colour.io.image.read_image_Imageio` definition unit tests methods. @@ -408,62 +407,62 @@ def test_read_image_Imageio(self): """Test :func:`colour.io.image.read_image_Imageio` definition.""" image = read_image_Imageio(os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr")) - self.assertTupleEqual(image.shape, (1267, 1274, 3)) - self.assertIs(image.dtype, np.dtype("float32")) + assert image.shape == (1267, 1274, 3) + assert image.dtype is np.dtype("float32") image = read_image_Imageio( os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr"), "float16", ) - self.assertTupleEqual(image.shape, (1267, 1274, 3)) - self.assertIs(image.dtype, np.dtype("float16")) + assert image.shape == (1267, 1274, 3) + assert image.dtype is np.dtype("float16") image = read_image_Imageio(os.path.join(ROOT_RESOURCES, "Single_Channel.exr")) - self.assertTupleEqual(image.shape, (256, 256)) + assert image.shape == (256, 256) image = read_image_Imageio( os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), "uint8" ) - self.assertTupleEqual(image.shape, (128, 256, 4)) - self.assertIs(image.dtype, np.dtype("uint8")) - self.assertEqual(np.min(image), 0) - self.assertEqual(np.max(image), 255) + assert image.shape == (128, 256, 4) + assert image.dtype is np.dtype("uint8") + assert np.min(image) == 0 + assert np.max(image) == 255 image = read_image_Imageio( os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), "uint16" ) - self.assertTupleEqual(image.shape, (128, 256, 4)) - self.assertIs(image.dtype, np.dtype("uint16")) - self.assertEqual(np.min(image), 0) - self.assertEqual(np.max(image), 65535) + assert image.shape == (128, 256, 4) + assert image.dtype is np.dtype("uint16") + assert np.min(image) == 0 + assert np.max(image) == 65535 image = read_image_Imageio( os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), "float16" ) - self.assertIs(image.dtype, np.dtype("float16")) - self.assertEqual(np.min(image), 0.0) - self.assertEqual(np.max(image), 1.0) + assert image.dtype is np.dtype("float16") + assert np.min(image) == 0.0 + assert np.max(image) == 1.0 image = read_image_Imageio( os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), "float32" ) - self.assertIs(image.dtype, np.dtype("float32")) - self.assertEqual(np.min(image), 0.0) - self.assertEqual(np.max(image), 1.0) + assert image.dtype is np.dtype("float32") + assert np.min(image) == 0.0 + assert np.max(image) == 1.0 -class TestWriteImageImageio(unittest.TestCase): +class TestWriteImageImageio: """ Define :func:`colour.io.image.write_image_Imageio` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def tearDown(self): + def teardown_method(self): """After tests actions.""" shutil.rmtree(self._temporary_directory) @@ -487,8 +486,8 @@ def test_write_image_Imageio(self): image = read_image_Imageio(source_image_path) write_image_Imageio(image, target_image_path) image = read_image_Imageio(target_image_path) - self.assertTupleEqual(image.shape, (1267, 1274, 3)) - self.assertIs(image.dtype, np.dtype("float32")) + assert image.shape == (1267, 1274, 3) + assert image.dtype is np.dtype("float32") # NOTE: Those unit tests are breaking unpredictably on Linux, skipping # for now. @@ -499,15 +498,15 @@ def test_write_image_Imageio(self): image = full((32, 16, 3), 1e6, dtype=np.float16) write_image_Imageio(image, target_image_path) image = read_image_Imageio(target_image_path) - self.assertEqual(np.max(image), np.inf) + assert np.max(image) == np.inf image = full((32, 16, 3), 1e6) write_image_Imageio(image, target_image_path) image = read_image_Imageio(target_image_path) - self.assertEqual(np.max(image), 1e6) + assert np.max(image) == 1e6 -class TestReadImage(unittest.TestCase): +class TestReadImage: """ Define :func:`colour.io.image.read_image` definition unit tests methods. @@ -517,22 +516,22 @@ def test_read_image(self): """Test :func:`colour.io.image.read_image` definition.""" image = read_image(os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr")) - self.assertTupleEqual(image.shape, (1267, 1274, 3)) - self.assertIs(image.dtype, np.dtype("float32")) + assert image.shape == (1267, 1274, 3) + assert image.dtype is np.dtype("float32") image = read_image(os.path.join(ROOT_RESOURCES, "Single_Channel.exr")) - self.assertTupleEqual(image.shape, (256, 256)) + assert image.shape == (256, 256) -class TestWriteImage(unittest.TestCase): +class TestWriteImage: """Define :func:`colour.io.image.write_image` definition unit tests methods.""" - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def tearDown(self): + def teardown_method(self): """After tests actions.""" shutil.rmtree(self._temporary_directory) @@ -547,11 +546,11 @@ def test_write_image(self): image = read_image(source_image_path) write_image(image, target_image_path) image = read_image(target_image_path) - self.assertTupleEqual(image.shape, (1267, 1274, 3)) - self.assertIs(image.dtype, np.dtype("float32")) + assert image.shape == (1267, 1274, 3) + assert image.dtype is np.dtype("float32") -class TestAs3ChannelsImage(unittest.TestCase): +class TestAs3ChannelsImage: """ Define :func:`colour.io.image.as_3_channels_image` definition unit tests methods. @@ -571,7 +570,3 @@ def test_as_3_channels_image(self): np.testing.assert_equal(as_3_channels_image(a), b) a = np.array([[[0.18, 0.18, 0.18]]]) np.testing.assert_equal(as_3_channels_image(a), b) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/io/tests/test_ocio.py b/colour/io/tests/test_ocio.py index a0308b4ee..b842bd4b2 100644 --- a/colour/io/tests/test_ocio.py +++ b/colour/io/tests/test_ocio.py @@ -4,7 +4,6 @@ from __future__ import annotations import os -import unittest import numpy as np @@ -27,7 +26,7 @@ ROOT_RESOURCES: str = os.path.join(os.path.dirname(__file__), "resources") -class TestProcessImageOpenColorIO(unittest.TestCase): +class TestProcessImageOpenColorIO: """ Define :func:`colour.io.ocio.process_image_OpenColorIO` definition unit tests methods. @@ -105,7 +104,3 @@ def test_process_image_OpenColorIO(self): ), atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/io/tests/test_tabular.py b/colour/io/tests/test_tabular.py index 9e02e3b0b..9a4799259 100644 --- a/colour/io/tests/test_tabular.py +++ b/colour/io/tests/test_tabular.py @@ -6,7 +6,8 @@ import os import shutil import tempfile -import unittest + +import pytest from colour.colorimetry import SpectralDistribution, SpectralShape from colour.io import ( @@ -117,7 +118,7 @@ } -class TestReadSpectralDataFromCsvFile(unittest.TestCase): +class TestReadSpectralDataFromCsvFile: """ Define :func:`colour.io.tabular.read_spectral_data_from_csv_file` definition unit tests methods. @@ -131,12 +132,8 @@ def test_read_spectral_data_from_csv_file(self): colour_checker_n_ohta = os.path.join(ROOT_RESOURCES, "colorchecker_n_ohta.csv") data = read_spectral_data_from_csv_file(colour_checker_n_ohta) - self.assertListEqual( - list(data.keys()), ["wavelength"] + [str(x) for x in range(1, 25)] - ) - self.assertDictEqual( - dict(zip(data["wavelength"], data["1"])), COLOURCHECKER_N_OHTA_1 - ) + assert list(data.keys()) == ["wavelength"] + [str(x) for x in range(1, 25)] + assert dict(zip(data["wavelength"], data["1"])) == COLOURCHECKER_N_OHTA_1 colour_checker_n_ohta_transposed = os.path.join( ROOT_RESOURCES, "colorchecker_n_ohta_transposed.csv" @@ -144,12 +141,8 @@ def test_read_spectral_data_from_csv_file(self): data = read_spectral_data_from_csv_file( colour_checker_n_ohta_transposed, transpose=True, delimiter="\t" ) - self.assertListEqual( - list(data.keys()), ["wavelength"] + [str(x) for x in range(1, 25)] - ) - self.assertDictEqual( - dict(zip(data["wavelength"], data["1"])), COLOURCHECKER_N_OHTA_1 - ) + assert list(data.keys()) == ["wavelength"] + [str(x) for x in range(1, 25)] + assert dict(zip(data["wavelength"], data["1"])) == COLOURCHECKER_N_OHTA_1 linss2_10e_5 = os.path.join(ROOT_RESOURCES, "linss2_10e_5.csv") data = read_spectral_data_from_csv_file( @@ -157,19 +150,17 @@ def test_read_spectral_data_from_csv_file(self): names=["wavelength", "l_bar", "m_bar", "s_bar"], filling_values=0, ) - self.assertListEqual( - list(data.keys()), ["wavelength", "l_bar", "m_bar", "s_bar"] - ) - self.assertEqual(data["s_bar"][77], 0) + assert list(data.keys()) == ["wavelength", "l_bar", "m_bar", "s_bar"] + assert data["s_bar"][77] == 0 data = read_spectral_data_from_csv_file( linss2_10e_5, names=["wavelength", "l_bar", "m_bar", "s_bar"], filling_values=-1, ) - self.assertEqual(data["s_bar"][77], -1) + assert data["s_bar"][77] == -1 -class TestReadSdsFromCsvFile(unittest.TestCase): +class TestReadSdsFromCsvFile: """ Define :func:`colour.io.tabular.read_sds_from_csv_file` definition unit tests methods. @@ -181,25 +172,23 @@ def test_read_sds_from_csv_file(self): colour_checker_n_ohta = os.path.join(ROOT_RESOURCES, "colorchecker_n_ohta.csv") sds = read_sds_from_csv_file(colour_checker_n_ohta) for sd in sds.values(): - self.assertIsInstance(sd, SpectralDistribution) + assert isinstance(sd, SpectralDistribution) - self.assertEqual( - sds["1"], SpectralDistribution(COLOURCHECKER_N_OHTA_1, name="1") - ) + assert sds["1"] == SpectralDistribution(COLOURCHECKER_N_OHTA_1, name="1") -class TestWriteSdsToCsvFile(unittest.TestCase): +class TestWriteSdsToCsvFile: """ Define :func:`colour.io.tabular.write_sds_to_csv_file` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def tearDown(self): + def teardown_method(self): """After tests actions.""" shutil.rmtree(self._temporary_directory) @@ -215,7 +204,7 @@ def test_write_sds_to_csv_file(self): write_sds_to_csv_file(sds, colour_checker_n_ohta_test) sds_test = read_sds_from_csv_file(colour_checker_n_ohta_test) for key, value in sds.items(): - self.assertEqual(value, sds_test[key]) + assert value == sds_test[key] def test_raise_exception_write_sds_to_csv_file(self): """ @@ -228,8 +217,4 @@ def test_raise_exception_write_sds_to_csv_file(self): key = next(iter(sds.keys())) sds[key] = sds[key].align(SpectralShape(400, 700, 10)) - self.assertRaises(ValueError, write_sds_to_csv_file, sds, "") - - -if __name__ == "__main__": - unittest.main() + pytest.raises(ValueError, write_sds_to_csv_file, sds, "") diff --git a/colour/io/tests/test_tm2714.py b/colour/io/tests/test_tm2714.py index 89b87d38d..be0a970ee 100644 --- a/colour/io/tests/test_tm2714.py +++ b/colour/io/tests/test_tm2714.py @@ -8,10 +8,10 @@ import shutil import tempfile import textwrap -import unittest from copy import deepcopy import numpy as np +import pytest from colour.colorimetry import SpectralDistribution from colour.constants import TOLERANCE_ABSOLUTE_TESTS @@ -145,13 +145,13 @@ } -class TestIES_TM2714_Header(unittest.TestCase): +class TestIES_TM2714_Header: """ Define :class:`colour.io.tm2714.Header_IESTM2714` class unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._header = Header_IESTM2714( @@ -187,7 +187,7 @@ def test_required_attributes(self): ) for attribute in required_attributes: - self.assertIn(attribute, dir(Header_IESTM2714)) + assert attribute in dir(Header_IESTM2714) def test_required_methods(self): """Test the presence of required methods.""" @@ -202,13 +202,12 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(Header_IESTM2714)) + assert method in dir(Header_IESTM2714) def test__str__(self): """Test :meth:`colour.io.tm2714.Header_IESTM2714.__str__` method.""" - self.assertEqual( - str(self._header), + assert str(self._header) == ( textwrap.dedent( """ Manufacturer : a @@ -223,14 +222,13 @@ def test__str__(self): Document Creation Date : j Comments : k """ - ).strip(), + ).strip() ) def test__repr__(self): """Test :meth:`colour.io.tm2714.Header_IESTM2714.__repr__` method.""" - self.assertEqual( - repr(self._header), + assert repr(self._header) == ( textwrap.dedent( """ Header_IESTM2714('a', @@ -245,16 +243,16 @@ def test__repr__(self): 'j', 'k') """ - ).strip(), + ).strip() ) def test__eq__(self): """Test :meth:`colour.io.tm2714.Header_IESTM2714.__eq__` method.""" header = deepcopy(self._header) - self.assertEqual(self._header, header) + assert self._header == header - self.assertNotEqual(self._header, None) + assert self._header is not None def test__ne__(self): """Test :meth:`colour.io.tm2714.Header_IESTM2714.__ne__` method.""" @@ -262,24 +260,24 @@ def test__ne__(self): header = deepcopy(self._header) header.manufacturer = "aa" - self.assertNotEqual(self._header, header) + assert self._header != header header.manufacturer = "a" - self.assertEqual(self._header, header) + assert self._header == header def test__hash__(self): """Test :meth:`colour.io.tm2714.Header_IESTM2714.__hash__` method.""" - self.assertIsInstance(hash(self._header), int) + assert isinstance(hash(self._header), int) -class TestIES_TM2714_Sd(unittest.TestCase): +class TestIES_TM2714_Sd: """ Define :class:`colour.io.tm2714.SpectralDistribution_IESTM2714` class unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() @@ -288,7 +286,7 @@ def setUp(self): os.path.join(ROOT_RESOURCES, "Fluorescent.spdx") ).read() - def tearDown(self): + def teardown_method(self): """After tests actions.""" shutil.rmtree(self._temporary_directory) @@ -308,7 +306,7 @@ def test_required_attributes(self): ) for attribute in required_attributes: - self.assertIn(attribute, dir(SpectralDistribution_IESTM2714)) + assert attribute in dir(SpectralDistribution_IESTM2714) def test_required_methods(self): """Test the presence of required methods.""" @@ -316,7 +314,7 @@ def test_required_methods(self): required_methods = ("__init__", "__str__", "__repr__", "read", "write") for method in required_methods: - self.assertIn(method, dir(SpectralDistribution_IESTM2714)) + assert method in dir(SpectralDistribution_IESTM2714) def test__str__(self): """ @@ -324,12 +322,11 @@ def test__str__(self): method. """ - self.assertEqual( - re.sub( - "Path :.*", - "Path :", - str(self._sd), - ), + assert re.sub( + "Path :.*", + "Path :", + str(self._sd), + ) == ( textwrap.dedent( """ IES TM-27-14 Spectral Distribution @@ -446,7 +443,7 @@ def test__str__(self): [ 8.12700000e+02 3.00000000e-02] [ 8.50100000e+02 3.00000000e-02]] """ - ).strip(), + ).strip() ) def test__repr__(self): @@ -455,12 +452,11 @@ def test__repr__(self): method. """ - self.assertEqual( - re.sub( - "SpectralDistribution_IESTM2714.*", - "SpectralDistribution_IESTM2714(...,", - repr(self._sd), - ), + assert re.sub( + "SpectralDistribution_IESTM2714.*", + "SpectralDistribution_IESTM2714(...,", + repr(self._sd), + ) == ( textwrap.dedent( """ SpectralDistribution_IESTM2714(..., @@ -570,7 +566,7 @@ def test__repr__(self): Extrapolator, {'method': 'Constant', 'left': None, 'right': None}) """ - ).strip(), + ).strip() ) def test_read(self, sd: SpectralDistribution | None = None): @@ -611,7 +607,7 @@ def test_read(self, sd: SpectralDistribution | None = None): for key, value in test.items(): for specification in read.mapping.elements: if key == specification.element: - self.assertEqual(getattr(read, specification.attribute), value) + assert getattr(read, specification.attribute) == value def test_raise_exception_read(self): """ @@ -620,9 +616,9 @@ def test_raise_exception_read(self): """ sd = SpectralDistribution_IESTM2714() - self.assertRaises(ValueError, sd.read) + pytest.raises(ValueError, sd.read) - with self.assertRaises(ValueError): + with pytest.raises(ValueError): sd = SpectralDistribution_IESTM2714( os.path.join(ROOT_RESOURCES, "Invalid.spdx") ) @@ -636,11 +632,11 @@ def test_write(self): sd_r = self._sd sd_r.path = os.path.join(self._temporary_directory, "Fluorescent.spdx") - self.assertTrue(sd_r.write()) + assert sd_r.write() sd_t = SpectralDistribution_IESTM2714(sd_r.path).read() self.test_read(sd_t) - self.assertEqual(sd_r, sd_t) + assert sd_r == sd_t for attribute in ( "manufacturer", @@ -655,10 +651,7 @@ def test_write(self): "document_creation_date", "comments", ): - self.assertEqual( - getattr(sd_r.header, attribute), - getattr(sd_t.header, attribute), - ) + assert getattr(sd_r.header, attribute) == getattr(sd_t.header, attribute) for attribute in ( "spectral_quantity", @@ -667,7 +660,7 @@ def test_write(self): "bandwidth_FWHM", "bandwidth_corrected", ): - self.assertEqual(getattr(sd_r, attribute), getattr(sd_t, attribute)) + assert getattr(sd_r, attribute) == getattr(sd_t, attribute) def test_raise_exception_write(self): """ @@ -676,8 +669,4 @@ def test_raise_exception_write(self): """ sd = SpectralDistribution_IESTM2714() - self.assertRaises(ValueError, sd.write) - - -if __name__ == "__main__": - unittest.main() + pytest.raises(ValueError, sd.write) diff --git a/colour/io/tests/test_uprtek_sekonic.py b/colour/io/tests/test_uprtek_sekonic.py index 96462b5e7..c52fc96df 100644 --- a/colour/io/tests/test_uprtek_sekonic.py +++ b/colour/io/tests/test_uprtek_sekonic.py @@ -4,7 +4,6 @@ import json import os -import unittest import numpy as np @@ -24,7 +23,7 @@ __status__ = "Production" __all__ = [ "ROOT_RESOURCES", - "AbstractSpectralDistributionTest", + "MixinTestAbstractSpectralDistribution", "TestSpectralDistributionUprTek", "TestSpectralDistributionSekonic", ] @@ -32,7 +31,7 @@ ROOT_RESOURCES: str = os.path.join(os.path.dirname(__file__), "resources") -class AbstractSpectralDistributionTest(unittest.TestCase): +class MixinTestAbstractSpectralDistribution: """ Define :class:`colour.SpectralDistribution_UPRTek`, :class:`colour.SpectralDistribution_Sekonic` classes common unit tests @@ -72,7 +71,7 @@ def test_required_attributes(self): ) for attribute in required_attributes: - self.assertIn(attribute, dir(SpectralDistribution_UPRTek)) + assert attribute in dir(SpectralDistribution_UPRTek) def test_required_methods(self): """Test the presence of required methods.""" @@ -80,7 +79,7 @@ def test_required_methods(self): required_methods = ("__init__", "__str__", "read", "write") for method in required_methods: - self.assertIn(method, dir(SpectralDistribution_UPRTek)) + assert method in dir(SpectralDistribution_UPRTek) def test__str__(self): """ @@ -91,11 +90,9 @@ def test__str__(self): if self._sd_factory is None: return - self.assertTrue( - str( - self._sd_factory(os.path.join(ROOT_RESOURCES, self._path)).read() - ).startswith(self._prefix) - ) + assert str( + self._sd_factory(os.path.join(ROOT_RESOURCES, self._path)).read() + ).startswith(self._prefix) def test_read(self): """ @@ -119,14 +116,12 @@ def test_read(self): for specification in sd.header.mapping.elements: if key == specification.element: if key == "Comments": - self.assertDictEqual(json.loads(sd.header.comments), value) + assert json.loads(sd.header.comments) == value else: - self.assertEqual( - getattr(sd.header, specification.attribute), value - ) + assert getattr(sd.header, specification.attribute) == value -class TestSpectralDistributionUprTek(AbstractSpectralDistributionTest): +class TestSpectralDistributionUprTek(MixinTestAbstractSpectralDistribution): """ Define :class:`colour.SpectralDistribution_UPRTek` class unit tests methods. @@ -607,7 +602,7 @@ def __init__(self, *args: Any) -> None: self._prefix = "UPRTek" -class TestSpectralDistributionSekonic(AbstractSpectralDistributionTest): +class TestSpectralDistributionSekonic(MixinTestAbstractSpectralDistribution): """ Define :class:`colour.SpectralDistribution_Sekonic` class unit tests methods. @@ -1112,7 +1107,3 @@ def __init__(self, *args: Any) -> None: "SpectralQuantity": "Irradiance", } self._prefix = "Sekonic" - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/io/tests/test_xrite.py b/colour/io/tests/test_xrite.py index 5dc7b641d..a97b7fa64 100644 --- a/colour/io/tests/test_xrite.py +++ b/colour/io/tests/test_xrite.py @@ -4,7 +4,6 @@ from __future__ import annotations import os -import unittest from colour.colorimetry import SpectralDistribution from colour.io import read_sds_from_xrite_file @@ -64,7 +63,7 @@ } -class TestReadSdsFromXRiteFile(unittest.TestCase): +class TestReadSdsFromXRiteFile: """ Define :func:`colour.io.xrite.read_sds_from_xrite_file` definition unit tests methods. @@ -78,12 +77,6 @@ def test_read_sds_from_xrite_file(self): ) sds = read_sds_from_xrite_file(colour_checker_xrite) for sd in sds.values(): - self.assertIsInstance(sd, SpectralDistribution) + assert isinstance(sd, SpectralDistribution) - self.assertEqual( - sds["X1"], SpectralDistribution(COLOURCHECKER_XRITE_1, name="X1") - ) - - -if __name__ == "__main__": - unittest.main() + assert sds["X1"] == SpectralDistribution(COLOURCHECKER_XRITE_1, name="X1") diff --git a/colour/models/rgb/datasets/tests/test__init__.py b/colour/models/rgb/datasets/tests/test__init__.py index 25fabba9d..07563a506 100644 --- a/colour/models/rgb/datasets/tests/test__init__.py +++ b/colour/models/rgb/datasets/tests/test__init__.py @@ -2,7 +2,6 @@ """Define the unit tests for the :mod:`colour.models.rgb.datasets` module.""" import pickle -import unittest from copy import deepcopy import numpy as np @@ -26,7 +25,7 @@ ] -class TestRGB_COLOURSPACES(unittest.TestCase): +class TestRGB_COLOURSPACES: """ Define :attr:`colour.models.rgb.datasets.RGB_COLOURSPACES` attribute unit tests methods. @@ -163,7 +162,3 @@ def test_pickle(self): for colourspace in RGB_COLOURSPACES.values(): pickle.dumps(colourspace) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/tests/test_cmyk.py b/colour/models/rgb/tests/test_cmyk.py index 863a73f57..e2c7a5a2b 100644 --- a/colour/models/rgb/tests/test_cmyk.py +++ b/colour/models/rgb/tests/test_cmyk.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.rgb.cmyk` module.""" -import unittest from itertools import product import numpy as np @@ -30,7 +29,7 @@ ] -class TestRGB_to_CMY(unittest.TestCase): +class TestRGB_to_CMY: """ Define :func:`colour.models.rgb.cmyk.RGB_to_CMY` definition unit tests methods. @@ -104,7 +103,7 @@ def test_nan_RGB_to_CMY(self): RGB_to_CMY(cases) -class TestCMY_to_RGB(unittest.TestCase): +class TestCMY_to_RGB: """ Define :func:`colour.models.rgb.cmyk.CMY_to_RGB` definition unit tests methods. @@ -175,7 +174,7 @@ def test_nan_CMY_to_RGB(self): CMY_to_RGB(cases) -class TestCMY_to_CMYK(unittest.TestCase): +class TestCMY_to_CMYK: """ Define :func:`colour.models.rgb.cmyk.CMY_to_CMYK` definition unit tests methods. @@ -253,7 +252,7 @@ def test_nan_CMY_to_CMYK(self): CMY_to_CMYK(cases) -class TestCMYK_to_CMY(unittest.TestCase): +class TestCMYK_to_CMY: """ Define :func:`colour.models.rgb.cmyk.CMYK_to_CMY` definition unit tests methods. @@ -329,7 +328,3 @@ def test_nan_CMYK_to_CMY(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=4)))) CMYK_to_CMY(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/tests/test_common.py b/colour/models/rgb/tests/test_common.py index 32502c04d..5da5c9a9d 100644 --- a/colour/models/rgb/tests/test_common.py +++ b/colour/models/rgb/tests/test_common.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.rgb.common` module.""" -import unittest import numpy as np @@ -21,7 +20,7 @@ ] -class TestXYZ_to_sRGB(unittest.TestCase): +class TestXYZ_to_sRGB: """ Define :func:`colour.models.rgb.common.XYZ_to_sRGB` definition unit tests methods. @@ -80,7 +79,7 @@ def test_XYZ_to_sRGB(self): ) -class TestsRGB_to_XYZ(unittest.TestCase): +class TestsRGB_to_XYZ: """ Define :func:`colour.models.rgb.common.sRGB_to_XYZ` definition unit tests methods. @@ -137,7 +136,3 @@ def test_sRGB_to_XYZ(self): np.array([0.20654291, 0.12197943, 0.05137141]), atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/tests/test_cylindrical.py b/colour/models/rgb/tests/test_cylindrical.py index cdc7837cd..ca38fb376 100644 --- a/colour/models/rgb/tests/test_cylindrical.py +++ b/colour/models/rgb/tests/test_cylindrical.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.rgb.cylindrical` module.""" -import unittest from itertools import product import numpy as np @@ -34,7 +33,7 @@ ] -class TestRGB_to_HSV(unittest.TestCase): +class TestRGB_to_HSV: """ Define :func:`colour.models.rgb.cylindrical.RGB_to_HSV` definition unit tests methods. @@ -114,7 +113,7 @@ def test_nan_RGB_to_HSV(self): RGB_to_HSV(cases) -class TestHSV_to_RGB(unittest.TestCase): +class TestHSV_to_RGB: """ Define :func:`colour.models.rgb.cylindrical.HSV_to_RGB` definition unit tests methods. @@ -194,7 +193,7 @@ def test_nan_HSV_to_RGB(self): HSV_to_RGB(cases) -class TestRGB_to_HSL(unittest.TestCase): +class TestRGB_to_HSL: """ Define :func:`colour.models.rgb.cylindrical.RGB_to_HSL` definition unit tests methods. @@ -274,7 +273,7 @@ def test_nan_RGB_to_HSL(self): RGB_to_HSL(cases) -class TestHSL_to_RGB(unittest.TestCase): +class TestHSL_to_RGB: """ Define :func:`colour.models.rgb.cylindrical.HSL_to_RGB` definition unit tests methods. @@ -354,7 +353,7 @@ def test_nan_HSL_to_RGB(self): HSL_to_RGB(cases) -class TestRGB_to_HCL(unittest.TestCase): +class TestRGB_to_HCL: """ Define :func:`colour.models.rgb.cylindrical.RGB_to_HCL` definition unit tests methods. @@ -434,7 +433,7 @@ def test_nan_RGB_to_HCL(self): RGB_to_HCL(cases) -class TestHCL_to_RGB(unittest.TestCase): +class TestHCL_to_RGB: """ Define :func:`colour.models.rgb.cylindrical.HCL_to_RGB` definition unit tests methods. @@ -512,7 +511,3 @@ def test_nan_HCL_to_RGB(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) HCL_to_RGB(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/tests/test_derivation.py b/colour/models/rgb/tests/test_derivation.py index 252d6b5f7..a1e37f199 100644 --- a/colour/models/rgb/tests/test_derivation.py +++ b/colour/models/rgb/tests/test_derivation.py @@ -3,7 +3,6 @@ import contextlib import re -import unittest from itertools import product import numpy as np @@ -37,7 +36,7 @@ ] -class Testxy_to_z(unittest.TestCase): +class Testxy_to_z: """ Define :func:`colour.models.rgb.derivation.xy_to_z` definition unit tests methods. @@ -96,7 +95,7 @@ def test_nan_xy_to_z(self): xy_to_z(cases) -class TestNormalisedPrimaryMatrix(unittest.TestCase): +class TestNormalisedPrimaryMatrix: """ Define :func:`colour.models.rgb.derivation.normalised_primary_matrix` definition unit tests methods. @@ -154,7 +153,7 @@ def test_nan_normalised_primary_matrix(self): normalised_primary_matrix(P, W) -class TestChromaticallyAdaptedPrimaries(unittest.TestCase): +class TestChromaticallyAdaptedPrimaries: """ Define :func:`colour.models.rgb.derivation.\ chromatically_adapted_primaries` definition unit tests methods. @@ -230,7 +229,7 @@ def test_nan_chromatically_adapted_primaries(self): chromatically_adapted_primaries(P, W, W) -class TestPrimariesWhitepoint(unittest.TestCase): +class TestPrimariesWhitepoint: """ Define :func:`colour.models.rgb.derivation.primaries_whitepoint` definition unit tests methods. @@ -306,7 +305,7 @@ def test_nan_primaries_whitepoint(self): primaries_whitepoint(M) -class TestRGBLuminanceEquation(unittest.TestCase): +class TestRGBLuminanceEquation: """ Define :func:`colour.models.rgb.derivation.RGB_luminance_equation` definition unit tests methods. @@ -318,7 +317,7 @@ def test_RGB_luminance_equation(self): definition. """ - self.assertIsInstance( + assert isinstance( RGB_luminance_equation( np.array([0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700]), np.array([0.32168, 0.33767]), @@ -334,15 +333,13 @@ def test_RGB_luminance_equation(self): "\\(B\\)" ) P = np.array([0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700]) - self.assertTrue( - re.match( - pattern, - RGB_luminance_equation(P, np.array([0.32168, 0.33767])), - ) + assert re.match( + pattern, + RGB_luminance_equation(P, np.array([0.32168, 0.33767])), ) -class TestRGBLuminance(unittest.TestCase): +class TestRGBLuminance: """ Define :func:`colour.models.rgb.derivation.RGB_luminance` definition unit tests methods. @@ -422,7 +419,3 @@ def test_nan_RGB_luminance(self): W = case[0:2] with contextlib.suppress(LinAlgError): RGB_luminance(RGB, P, W) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/tests/test_hanbury2003.py b/colour/models/rgb/tests/test_hanbury2003.py index 7c510911c..4b99607b0 100644 --- a/colour/models/rgb/tests/test_hanbury2003.py +++ b/colour/models/rgb/tests/test_hanbury2003.py @@ -1,6 +1,5 @@ """Defines unit tests for :mod:`colour.models.rgb.hanbury2003` module.""" -import unittest from itertools import product import numpy as np @@ -22,7 +21,7 @@ ] -class TestRGB_to_IHLS(unittest.TestCase): +class TestRGB_to_IHLS: """ Define :func:`colour.models.rgb.hanbury2003.RGB_to_IHLS` definition unit tests methods. @@ -96,7 +95,7 @@ def test_nan_RGB_to_IHLS(self): RGB_to_IHLS(cases) -class TestIHLS_to_RGB(unittest.TestCase): +class TestIHLS_to_RGB: """ Define :func:`colour.models.rgb.hanbury2003.RGB_to_IHLS` definition unit tests methods. @@ -168,7 +167,3 @@ def test_nan_IHLS_to_RGB(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) IHLS_to_RGB(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/tests/test_ictcp.py b/colour/models/rgb/tests/test_ictcp.py index 475dfb798..885d31fd2 100644 --- a/colour/models/rgb/tests/test_ictcp.py +++ b/colour/models/rgb/tests/test_ictcp.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.rgb.ictcp` module.""" -import unittest from itertools import product import numpy as np @@ -30,7 +29,7 @@ ] -class TestRGB_to_ICtCp(unittest.TestCase): +class TestRGB_to_ICtCp: """ Define :func:`colour.models.rgb.ictcp.TestRGB_to_ICtCp` definition unit tests methods. @@ -144,7 +143,7 @@ def test_nan_RGB_to_ICtCp(self): RGB_to_ICtCp(cases) -class TestICtCp_to_RGB(unittest.TestCase): +class TestICtCp_to_RGB: """ Define :func:`colour.models.rgb.ictcp.ICtCp_to_RGB` definition unit tests methods. @@ -258,7 +257,7 @@ def test_nan_ICtCp_to_RGB(self): ICtCp_to_RGB(cases) -class TestXYZ_to_ICtCp(unittest.TestCase): +class TestXYZ_to_ICtCp: """ Define :func:`colour.models.rgb.ictcp.TestXYZ_to_ICtCp` definition unit tests methods. @@ -391,7 +390,7 @@ def test_nan_XYZ_to_ICtCp(self): XYZ_to_ICtCp(cases) -class TestICtCp_to_XYZ(unittest.TestCase): +class TestICtCp_to_XYZ: """ Define :func:`colour.models.rgb.ictcp.ICtCp_to_XYZ` definition unit tests methods. @@ -522,7 +521,3 @@ def test_nan_ICtCp_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) ICtCp_to_XYZ(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/tests/test_itut_h_273.py b/colour/models/rgb/tests/test_itut_h_273.py index a1c4ad96f..06c73e340 100644 --- a/colour/models/rgb/tests/test_itut_h_273.py +++ b/colour/models/rgb/tests/test_itut_h_273.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.rgb.itut_h_273` module.""" -import unittest from colour.models import ( describe_video_signal_colour_primaries, @@ -23,7 +22,7 @@ ] -class TestDescribeVideoSignalColourPrimaries(unittest.TestCase): +class TestDescribeVideoSignalColourPrimaries: """ Define :func:`colour.models.rgb.itut_h_273.\ describe_video_signal_colour_primaries` definition unit tests methods. @@ -37,10 +36,10 @@ def test_describe_video_signal_colour_primaries(self): """ description = describe_video_signal_colour_primaries(1) - self.assertIsInstance(description, str) + assert isinstance(description, str) -class TestDescribeVideoSignalTransferCharacteristics(unittest.TestCase): +class TestDescribeVideoSignalTransferCharacteristics: """ Define :func:`colour.models.rgb.itut_h_273.\ describe_video_signal_transfer_characteristics` definition unit tests methods. @@ -53,10 +52,10 @@ def test_describe_video_signal_transfer_characteristics(self): """ description = describe_video_signal_transfer_characteristics(1) - self.assertIsInstance(description, str) + assert isinstance(description, str) -class TestDescribeVideoSignalMatrixCoefficients(unittest.TestCase): +class TestDescribeVideoSignalMatrixCoefficients: """ Define :func:`colour.models.rgb.itut_h_273.\ describe_video_signal_matrix_coefficients` definition unit tests methods. @@ -69,8 +68,4 @@ def test_describe_video_signal_matrix_coefficients(self): """ description = describe_video_signal_matrix_coefficients(1) - self.assertIsInstance(description, str) - - -if __name__ == "__main__": - unittest.main() + assert isinstance(description, str) diff --git a/colour/models/rgb/tests/test_prismatic.py b/colour/models/rgb/tests/test_prismatic.py index 2bd138042..b5bae8507 100644 --- a/colour/models/rgb/tests/test_prismatic.py +++ b/colour/models/rgb/tests/test_prismatic.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.rgb.prismatic` module.""" -import unittest from itertools import product import numpy as np @@ -23,7 +22,7 @@ ] -class TestRGB_to_Prismatic(unittest.TestCase): +class TestRGB_to_Prismatic: """ Define :func:`colour.models.rgb.prismatic.TestRGB_to_Prismatic` definition unit tests methods. @@ -95,7 +94,7 @@ def test_nan_RGB_to_Prismatic(self): RGB_to_Prismatic(cases) -class TestPrismatic_to_RGB(unittest.TestCase): +class TestPrismatic_to_RGB: """ Define :func:`colour.models.rgb.prismatic.Prismatic_to_RGB` definition unit tests methods. @@ -165,7 +164,3 @@ def test_nan_Prismatic_to_RGB(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) Prismatic_to_RGB(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/tests/test_rgb_colourspace.py b/colour/models/rgb/tests/test_rgb_colourspace.py index 29955fc48..43d9d72f9 100644 --- a/colour/models/rgb/tests/test_rgb_colourspace.py +++ b/colour/models/rgb/tests/test_rgb_colourspace.py @@ -5,7 +5,6 @@ import re import textwrap -import unittest from itertools import product import numpy as np @@ -44,13 +43,13 @@ ] -class TestRGB_Colourspace(unittest.TestCase): +class TestRGB_Colourspace: """ Define :class:`colour.colour.models.RGB_Colourspace` class unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" p = np.array([0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700]) @@ -85,7 +84,7 @@ def test_required_attributes(self): ) for attribute in required_attributes: - self.assertIn(attribute, dir(RGB_Colourspace)) + assert attribute in dir(RGB_Colourspace) def test_required_methods(self): """Test the presence of required methods.""" @@ -100,7 +99,7 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(RGB_Colourspace)) + assert method in dir(RGB_Colourspace) def test__str__(self): """ @@ -108,8 +107,7 @@ def test__str__(self): method. """ - self.assertEqual( - re.sub(" at 0x\\w+>", "", str(self._colourspace)), + assert re.sub(" at 0x\\w+>", "", str(self._colourspace)) == ( textwrap.dedent( """ RGB Colourspace @@ -137,7 +135,7 @@ def test__str__(self): Use Derived NPM : False Use Derived NPM -1 : False """ - ).strip(), + ).strip() ) def test__repr__(self): @@ -146,8 +144,7 @@ def test__repr__(self): __repr__` method. """ - self.assertEqual( - re.sub(" at 0x\\w+>", "", repr(self._colourspace)), + assert re.sub(" at 0x\\w+>", "", repr(self._colourspace)) == ( textwrap.dedent( """ RGB_Colourspace('RGB Colourspace', @@ -167,7 +164,7 @@ def test__repr__(self): False, False) """ - ).strip(), + ).strip() ) def test_use_derived_transformation_matrices(self): @@ -243,7 +240,7 @@ def test_chromatically_adapt(self): colourspace.whitepoint, whitepoint_t, atol=TOLERANCE_ABSOLUTE_TESTS ) - self.assertEqual(colourspace.whitepoint_name, "D50") + assert colourspace.whitepoint_name == "D50" np.testing.assert_allclose( colourspace.primaries, @@ -276,10 +273,10 @@ def test_copy(self): method. """ - self.assertIsNot(self._colourspace.copy(), self) + assert self._colourspace.copy() is not self -class TestXYZ_to_RGB(unittest.TestCase): +class TestXYZ_to_RGB: """ Define :func:`colour.models.rgb.rgb_colourspace.XYZ_to_RGB` definition unit tests methods. @@ -480,7 +477,7 @@ def test_nan_XYZ_to_RGB(self): XYZ_to_RGB(cases, cases[..., 0:2], cases[..., 0:2], M) -class TestRGB_to_XYZ(unittest.TestCase): +class TestRGB_to_XYZ: """ Define :func:`colour.models.rgb.rgb_colourspace.RGB_to_XYZ` definition unit tests methods. @@ -681,7 +678,7 @@ def test_nan_RGB_to_XYZ(self): RGB_to_XYZ(cases, cases[..., 0:2], cases[..., 0:2], M) -class TestMatrix_RGB_to_RGB(unittest.TestCase): +class TestMatrix_RGB_to_RGB: """ Define :func:`colour.models.rgb.rgb_colourspace.matrix_RGB_to_RGB` definition unit tests methods. @@ -764,7 +761,7 @@ def test_matrix_RGB_to_RGB(self): ) -class TestRGB_to_RGB(unittest.TestCase): +class TestRGB_to_RGB: """ Define :func:`colour.models.rgb.rgb_colourspace.RGB_to_RGB` definition unit tests methods. @@ -934,7 +931,3 @@ def test_nan_RGB_to_RGB(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) RGB_to_RGB(cases, aces_2065_1_colourspace, sRGB_colourspace) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/tests/test_ycbcr.py b/colour/models/rgb/tests/test_ycbcr.py index 24b3bffbf..e64277493 100644 --- a/colour/models/rgb/tests/test_ycbcr.py +++ b/colour/models/rgb/tests/test_ycbcr.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.rgb.ycbcr` module.""" -import unittest from itertools import product import numpy as np @@ -39,7 +38,7 @@ ] -class TestRoundBT2100(unittest.TestCase): +class TestRoundBT2100: """ Define :func:`colour.models.rgb.ycbcr.round_BT2100` definition unit tests methods. @@ -54,7 +53,7 @@ def test_round_BT2100(self): ) -class TestRangeYCbCr(unittest.TestCase): +class TestRangeYCbCr: """ Define :func:`colour.models.rgb.ycbcr.ranges_YCbCr` definition unit tests methods. @@ -112,7 +111,7 @@ def test_ranges_YCbCr(self): ) -class TestMatrixYCbCr(unittest.TestCase): +class TestMatrixYCbCr: """ Define :func:`colour.models.rgb.ycbcr.matrix_YCbCr` definition unit tests methods. @@ -182,7 +181,7 @@ def test_matrix_YCbCr(self): ) -class TestOffsetYCbCr(unittest.TestCase): +class TestOffsetYCbCr: """ Define :func:`colour.models.rgb.ycbcr.offset_YCbCr` definition unit tests methods. @@ -216,7 +215,7 @@ def test_offset_YCbCr(self): ) -class TestRGB_to_YCbCr(unittest.TestCase): +class TestRGB_to_YCbCr: """ Define :func:`colour.models.rgb.ycbcr.RGB_to_YCbCr` definition unit tests methods. @@ -321,7 +320,7 @@ def test_nan_RGB_to_YCbCr(self): RGB_to_YCbCr(cases) -class TestYCbCr_to_RGB(unittest.TestCase): +class TestYCbCr_to_RGB: """ Define :func:`colour.models.rgb.ycbcr.YCbCr_to_RGB` definition unit tests methods. @@ -418,7 +417,7 @@ def test_nan_YCbCr_to_RGB(self): YCbCr_to_RGB(cases) -class TestRGB_to_YcCbcCrc(unittest.TestCase): +class TestRGB_to_YcCbcCrc: """ Define :func:`colour.models.rgb.ycbcr.RGB_to_YcCbcCrc` definition unit tests methods. @@ -508,7 +507,7 @@ def test_nan_RGB_to_YcCbcCrc(self): RGB_to_YcCbcCrc(cases) -class TestYcCbcCrc_to_RGB(unittest.TestCase): +class TestYcCbcCrc_to_RGB: """ Define :func:`colour.models.rgb.ycbcr.YCbCr_to_RGB` definition unit tests methods. @@ -596,7 +595,3 @@ def test_nan_YcCbcCrc_to_RGB(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) YcCbcCrc_to_RGB(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/tests/test_ycocg.py b/colour/models/rgb/tests/test_ycocg.py index 05630a2a8..dc51239cb 100644 --- a/colour/models/rgb/tests/test_ycocg.py +++ b/colour/models/rgb/tests/test_ycocg.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.rgb.ycocg` module.""" -import unittest from itertools import product import numpy as np @@ -23,7 +22,7 @@ ] -class TestRGB_to_YCoCg(unittest.TestCase): +class TestRGB_to_YCoCg: """ Define :func:`colour.models.rgb.ycocg.RGB_to_YCoCg` definition unit tests methods. @@ -92,7 +91,7 @@ def test_nan_RGB_to_YCoCg(self): RGB_to_YCoCg(cases) -class TestYCoCg_to_RGB(unittest.TestCase): +class TestYCoCg_to_RGB: """ Define :func:`colour.models.rgb.ycocg.YCoCg_to_RGB` definition unit tests methods. @@ -159,7 +158,3 @@ def test_nan_YCoCg_to_RGB(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) YCoCg_to_RGB(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test__init__.py b/colour/models/rgb/transfer_functions/tests/test__init__.py index e17efcfa9..ff9b2d27b 100644 --- a/colour/models/rgb/transfer_functions/tests/test__init__.py +++ b/colour/models/rgb/transfer_functions/tests/test__init__.py @@ -3,9 +3,9 @@ :mod:`colour.models.rgb.transfer_functions.common` module. """ -import unittest import numpy as np +import pytest from colour.constants import TOLERANCE_ABSOLUTE_TESTS from colour.models.rgb.transfer_functions import ( @@ -38,7 +38,7 @@ ] -class TestCctfEncoding(unittest.TestCase): +class TestCctfEncoding: """ Define :func:`colour.models.rgb.transfer_functions.cctf_encoding` definition unit tests methods. @@ -50,13 +50,13 @@ def test_raise_exception_cctf_encoding(self): log_encoding_ACESproxy` definition raised exception. """ - self.assertWarns( + pytest.warns( ColourUsageWarning, cctf_encoding, 0.18, function="ITU-R BT.2100 HLG", ) - self.assertWarns( + pytest.warns( ColourUsageWarning, cctf_encoding, 0.18, @@ -64,7 +64,7 @@ def test_raise_exception_cctf_encoding(self): ) -class TestCctfDecoding(unittest.TestCase): +class TestCctfDecoding: """ Define :func:`colour.models.rgb.transfer_functions.cctf_decoding` definition unit tests methods. @@ -76,13 +76,13 @@ def test_raise_exception_cctf_decoding(self): log_encoding_ACESproxy` definition raised exception. """ - self.assertWarns( + pytest.warns( ColourUsageWarning, cctf_decoding, 0.18, function="ITU-R BT.2100 HLG", ) - self.assertWarns( + pytest.warns( ColourUsageWarning, cctf_decoding, 0.18, @@ -90,7 +90,7 @@ def test_raise_exception_cctf_decoding(self): ) -class TestTransferFunctions(unittest.TestCase): +class TestTransferFunctions: """Define the transfer functions unit tests methods.""" def test_transfer_functions(self): @@ -137,7 +137,3 @@ def test_transfer_functions(self): samples_d, atol=tolerance.get(name, TOLERANCE_ABSOLUTE_TESTS), ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_aces.py b/colour/models/rgb/transfer_functions/tests/test_aces.py index b50b429e3..5d4da46cd 100644 --- a/colour/models/rgb/transfer_functions/tests/test_aces.py +++ b/colour/models/rgb/transfer_functions/tests/test_aces.py @@ -3,7 +3,6 @@ module. """ -import unittest import numpy as np @@ -34,7 +33,7 @@ ] -class TestLogEncoding_ACESproxy(unittest.TestCase): +class TestLogEncoding_ACESproxy: """ Define :func:`colour.models.rgb.transfer_functions.aces.\ log_encoding_ACESproxy` @@ -71,7 +70,7 @@ def test_log_encoding_ACESproxy(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual(log_encoding_ACESproxy(0.18, out_int=True), 426) + assert log_encoding_ACESproxy(0.18, out_int=True) == 426 def test_n_dimensional_log_encoding_ACESproxy(self): """ @@ -134,7 +133,7 @@ def test_nan_log_encoding_ACESproxy(self): log_encoding_ACESproxy(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_ACESproxy(unittest.TestCase): +class TestLogDecoding_ACESproxy: """ Define :func:`colour.models.rgb.transfer_functions.aces.\ log_decoding_ACESproxy` @@ -238,7 +237,7 @@ def test_nan_log_decoding_ACESproxy(self): log_decoding_ACESproxy(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogEncoding_ACEScc(unittest.TestCase): +class TestLogEncoding_ACEScc: """ Define :func:`colour.models.rgb.transfer_functions.aces.\ log_encoding_ACEScc` definition unit tests methods. @@ -323,7 +322,7 @@ def test_nan_log_encoding_ACEScc(self): log_encoding_ACEScc(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_ACEScc(unittest.TestCase): +class TestLogDecoding_ACEScc: """ Define :func:`colour.models.rgb.transfer_functions.aces.\ log_decoding_ACEScc` definition unit tests methods. @@ -408,7 +407,7 @@ def test_nan_log_decoding_ACEScc(self): log_decoding_ACEScc(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogEncoding_ACEScct(unittest.TestCase): +class TestLogEncoding_ACEScct: """ Define :func:`colour.models.rgb.transfer_functions.aces.\ log_encoding_ACEScct` definition unit tests methods. @@ -515,7 +514,7 @@ def test_nan_log_encoding_ACEScct(self): log_encoding_ACEScct(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_ACEScct(unittest.TestCase): +class TestLogDecoding_ACEScct: """ Define :func:`colour.models.rgb.transfer_functions.aces.\ log_decoding_ACEScct` definition unit tests methods. @@ -620,7 +619,3 @@ def test_nan_log_decoding_ACEScct(self): """ log_decoding_ACEScct(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_apple_log_profile.py b/colour/models/rgb/transfer_functions/tests/test_apple_log_profile.py index 9777a41f5..fecf6f380 100644 --- a/colour/models/rgb/transfer_functions/tests/test_apple_log_profile.py +++ b/colour/models/rgb/transfer_functions/tests/test_apple_log_profile.py @@ -3,7 +3,6 @@ apple_log_profile` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestLogEncoding_AppleLogProfile(unittest.TestCase): +class TestLogEncoding_AppleLogProfile: """ Define :func:`colour.models.rgb.transfer_functions.apple_log_profile.\ log_encoding_AppleLogProfile` definition unit tests methods. @@ -114,7 +113,7 @@ def test_nan_log_encoding_DLog(self): ) -class TestLogDecoding_AppleLogProfile(unittest.TestCase): +class TestLogDecoding_AppleLogProfile: """ Define :func:`colour.models.rgb.transfer_functions.apple_log_profile.\ log_decoding_AppleLogProfile` definition unit tests methods. @@ -199,7 +198,3 @@ def test_nan_log_decoding_DLog(self): log_decoding_AppleLogProfile( np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]) ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_arib_std_b67.py b/colour/models/rgb/transfer_functions/tests/test_arib_std_b67.py index e956047b8..6eaf8f4eb 100644 --- a/colour/models/rgb/transfer_functions/tests/test_arib_std_b67.py +++ b/colour/models/rgb/transfer_functions/tests/test_arib_std_b67.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.arib_std_b67` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestOetf_ARIBSTDB67(unittest.TestCase): +class TestOetf_ARIBSTDB67: """ Define :func:`colour.models.rgb.transfer_functions.arib_std_b67.\ oetf_ARIBSTDB67` definition unit tests methods. @@ -118,7 +117,7 @@ def test_nan_oetf_ARIBSTDB67(self): oetf_ARIBSTDB67(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOetf_inverse_ARIBSTDB67(unittest.TestCase): +class TestOetf_inverse_ARIBSTDB67: """ Define :func:`colour.models.rgb.transfer_functions.arib_std_b67.\ oetf_inverse_ARIBSTDB67` definition unit tests methods. @@ -209,7 +208,3 @@ def test_nan_oetf_inverse_ARIBSTDB67(self): """ oetf_inverse_ARIBSTDB67(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_arri.py b/colour/models/rgb/transfer_functions/tests/test_arri.py index 5b3d4de61..96e79bbe0 100644 --- a/colour/models/rgb/transfer_functions/tests/test_arri.py +++ b/colour/models/rgb/transfer_functions/tests/test_arri.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.arri` module. """ -import unittest import numpy as np @@ -31,7 +30,7 @@ ] -class TestLogEncoding_ARRILogC3(unittest.TestCase): +class TestLogEncoding_ARRILogC3: """ Define :func:`colour.models.rgb.transfer_functions.arri.\ log_encoding_ARRILogC3` definition unit tests methods. @@ -116,7 +115,7 @@ def test_nan_log_encoding_ARRILogC3(self): log_encoding_ARRILogC3(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_ARRILogC3(unittest.TestCase): +class TestLogDecoding_ARRILogC3: """ Define :func:`colour.models.rgb.transfer_functions.arri.\ log_decoding_ARRILogC3` definition unit tests methods. @@ -201,7 +200,7 @@ def test_nan_log_decoding_ARRILogC3(self): log_decoding_ARRILogC3(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogEncoding_ARRILogC4(unittest.TestCase): +class TestLogEncoding_ARRILogC4: """ Define :func:`colour.models.rgb.transfer_functions.arri.\ log_encoding_ARRILogC4` definition unit tests methods. @@ -286,7 +285,7 @@ def test_nan_log_encoding_ARRILogC4(self): log_encoding_ARRILogC4(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_ARRILogC4(unittest.TestCase): +class TestLogDecoding_ARRILogC4: """ Define :func:`colour.models.rgb.transfer_functions.arri.\ log_decoding_ARRILogC4` definition unit tests methods. @@ -369,7 +368,3 @@ def test_nan_log_decoding_ARRILogC4(self): """ log_decoding_ARRILogC4(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_blackmagic_design.py b/colour/models/rgb/transfer_functions/tests/test_blackmagic_design.py index a0ff54445..ea5e403ce 100644 --- a/colour/models/rgb/transfer_functions/tests/test_blackmagic_design.py +++ b/colour/models/rgb/transfer_functions/tests/test_blackmagic_design.py @@ -3,7 +3,6 @@ blackmagic_design` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestOetf_BlackmagicFilmGeneration5(unittest.TestCase): +class TestOetf_BlackmagicFilmGeneration5: """ Define :func:`colour.models.rgb.transfer_functions.blackmagic_design.\ oetf_BlackmagicFilmGeneration5` definition unit tests methods. @@ -128,7 +127,7 @@ def test_nan_oetf_BlackmagicFilmGeneration5(self): ) -class TestOetf_inverse_BlackmagicFilmGeneration5(unittest.TestCase): +class TestOetf_inverse_BlackmagicFilmGeneration5: """ Define :func:`colour.models.rgb.transfer_functions.\ blackmagic_design.oetf_inverse_BlackmagicFilmGeneration5` definition unit tests @@ -235,7 +234,3 @@ def test_nan_oetf_inverse_BlackmagicFilmGeneration5(self): oetf_inverse_BlackmagicFilmGeneration5( np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]) ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_canon.py b/colour/models/rgb/transfer_functions/tests/test_canon.py index a8d6ce107..8cccb13b5 100644 --- a/colour/models/rgb/transfer_functions/tests/test_canon.py +++ b/colour/models/rgb/transfer_functions/tests/test_canon.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.canon` module. """ -import unittest import numpy as np @@ -47,7 +46,7 @@ ] -class TestLogEncoding_CanonLog_v1(unittest.TestCase): +class TestLogEncoding_CanonLog_v1: """ Define :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog_v1` definition unit tests methods. @@ -156,7 +155,7 @@ def test_nan_log_encoding_CanonLog_v1(self): log_encoding_CanonLog_v1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_CanonLog_v1(unittest.TestCase): +class TestLogDecoding_CanonLog_v1: """ Define :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog_v1` definition unit tests methods. @@ -265,7 +264,7 @@ def test_nan_log_decoding_CanonLog_v1(self): log_decoding_CanonLog_v1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogEncoding_CanonLog_v1_2(unittest.TestCase): +class TestLogEncoding_CanonLog_v1_2: """ Define :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog_v1_2` definition unit tests methods. @@ -399,7 +398,7 @@ def test_nan_log_encoding_CanonLog_v1_2(self): log_encoding_CanonLog_v1_2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_CanonLog_v1_2(unittest.TestCase): +class TestLogDecoding_CanonLog_v1_2: """ Define :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog_v1_2` definition unit tests methods. @@ -533,7 +532,7 @@ def test_nan_log_decoding_CanonLog_v1_2(self): log_decoding_CanonLog_v1_2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogEncoding_CanonLog2_v1(unittest.TestCase): +class TestLogEncoding_CanonLog2_v1: """ Define :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog2_v1` definition unit tests methods. @@ -642,7 +641,7 @@ def test_nan_log_encoding_CanonLog2_v1(self): log_encoding_CanonLog2_v1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_CanonLog2_v1(unittest.TestCase): +class TestLogDecoding_CanonLog2_v1: """ Define :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog2_v1` definition unit tests methods. @@ -751,7 +750,7 @@ def test_nan_log_decoding_CanonLog2_v1(self): log_decoding_CanonLog2_v1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogEncoding_CanonLog2_v1_2(unittest.TestCase): +class TestLogEncoding_CanonLog2_v1_2: """ Define :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog2_v1_2` definition unit tests methods. @@ -891,7 +890,7 @@ def test_nan_log_encoding_CanonLog2_v1_2(self): log_encoding_CanonLog2_v1_2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_CanonLog2_v1_2(unittest.TestCase): +class TestLogDecoding_CanonLog2_v1_2: """ Define :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog2_v1_2` definition unit tests methods. @@ -1031,7 +1030,7 @@ def test_nan_log_decoding_CanonLog2_v1_2(self): log_decoding_CanonLog2_v1_2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogEncoding_CanonLog3_v1(unittest.TestCase): +class TestLogEncoding_CanonLog3_v1: """ Define :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog3_v1` definition unit tests methods. @@ -1140,7 +1139,7 @@ def test_nan_log_encoding_CanonLog3_v1(self): log_encoding_CanonLog3_v1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_CanonLog3_v1(unittest.TestCase): +class TestLogDecoding_CanonLog3_v1: """ Define :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog3_v1` definition unit tests methods. @@ -1249,7 +1248,7 @@ def test_nan_log_decoding_CanonLog3_v1(self): log_decoding_CanonLog3_v1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogEncoding_CanonLog3_v1_2(unittest.TestCase): +class TestLogEncoding_CanonLog3_v1_2: """ Define :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog3_v1_2` definition unit tests methods. @@ -1389,7 +1388,7 @@ def test_nan_log_encoding_CanonLog3_v1_2(self): log_encoding_CanonLog3_v1_2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_CanonLog3_v1_2(unittest.TestCase): +class TestLogDecoding_CanonLog3_v1_2: """ Define :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog3_v1_2` definition unit tests methods. @@ -1527,7 +1526,3 @@ def test_nan_log_decoding_CanonLog3_v1_2(self): """ log_decoding_CanonLog3_v1_2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_cineon.py b/colour/models/rgb/transfer_functions/tests/test_cineon.py index 206381395..943db9cc5 100644 --- a/colour/models/rgb/transfer_functions/tests/test_cineon.py +++ b/colour/models/rgb/transfer_functions/tests/test_cineon.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.cineon` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestLogEncoding_Cineon(unittest.TestCase): +class TestLogEncoding_Cineon: """ Define :func:`colour.models.rgb.transfer_functions.cineon.\ log_encoding_Cineon` definition unit tests methods. @@ -112,7 +111,7 @@ def test_nan_log_encoding_Cineon(self): log_encoding_Cineon(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_Cineon(unittest.TestCase): +class TestLogDecoding_Cineon: """ Define :func:`colour.models.rgb.transfer_functions.cineon.\ log_decoding_Cineon` definition unit tests methods. @@ -195,7 +194,3 @@ def test_nan_log_decoding_Cineon(self): """ log_decoding_Cineon(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_common.py b/colour/models/rgb/transfer_functions/tests/test_common.py index 516e5da04..e13d015d2 100644 --- a/colour/models/rgb/transfer_functions/tests/test_common.py +++ b/colour/models/rgb/transfer_functions/tests/test_common.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.common` module. """ -import unittest import numpy as np @@ -29,7 +28,7 @@ ] -class TestCV_range(unittest.TestCase): +class TestCV_range: """ Define :func:`colour.models.rgb.transfer_functions.common.CV_range` definition unit tests methods. @@ -66,7 +65,7 @@ def test_CV_range(self): np.testing.assert_array_equal(CV_range(10, False, False), np.array([0, 1])) -class TestLegalToFull(unittest.TestCase): +class TestLegalToFull: """ Define :func:`colour.models.rgb.transfer_functions.common.legal_to_full` definition unit tests methods. @@ -131,7 +130,7 @@ def test_nan_legal_to_full(self): legal_to_full(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]), 10) -class TestFullToLegal(unittest.TestCase): +class TestFullToLegal: """ Define :func:`colour.models.rgb.transfer_functions.common.full_to_legal` definition unit tests methods. @@ -194,7 +193,3 @@ def test_nan_full_to_legal(self): """ full_to_legal(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]), 10) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_davinci_intermediate.py b/colour/models/rgb/transfer_functions/tests/test_davinci_intermediate.py index b098df4d2..a9b561c70 100644 --- a/colour/models/rgb/transfer_functions/tests/test_davinci_intermediate.py +++ b/colour/models/rgb/transfer_functions/tests/test_davinci_intermediate.py @@ -3,7 +3,6 @@ davinci_intermediate` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestOetf_DaVinciIntermediate(unittest.TestCase): +class TestOetf_DaVinciIntermediate: """ Define :func:`colour.models.rgb.transfer_functions.davinci_intermediate.\ oetf_DaVinciIntermediate` definition unit tests methods. @@ -124,7 +123,7 @@ def test_nan_oetf_DaVinciIntermediate(self): oetf_DaVinciIntermediate(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOetf_inverse_DaVinciIntermediate(unittest.TestCase): +class TestOetf_inverse_DaVinciIntermediate: """ Define :func:`colour.models.rgb.transfer_functions.\ davinci_intermediate.oetf_inverse_DaVinciIntermediate` definition unit tests @@ -230,7 +229,3 @@ def test_nan_oetf_inverse_DaVinciIntermediate(self): oetf_inverse_DaVinciIntermediate( np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]) ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_dcdm.py b/colour/models/rgb/transfer_functions/tests/test_dcdm.py index 8cf806b46..32d1aae3d 100644 --- a/colour/models/rgb/transfer_functions/tests/test_dcdm.py +++ b/colour/models/rgb/transfer_functions/tests/test_dcdm.py @@ -3,7 +3,6 @@ module. """ -import unittest import numpy as np @@ -24,7 +23,7 @@ ] -class TestEotf_inverse_DCDM(unittest.TestCase): +class TestEotf_inverse_DCDM: """ Define :func:`colour.models.rgb.transfer_functions.dcdm.eotf_inverse_DCDM` definition unit tests methods. @@ -48,7 +47,7 @@ def test_eotf_inverse_DCDM(self): eotf_inverse_DCDM(1.0), 0.21817973, atol=TOLERANCE_ABSOLUTE_TESTS ) - self.assertEqual(eotf_inverse_DCDM(0.18, out_int=True), 462) + assert eotf_inverse_DCDM(0.18, out_int=True) == 462 def test_n_dimensional_eotf_inverse_DCDM(self): """ @@ -105,7 +104,7 @@ def test_nan_eotf_inverse_DCDM(self): eotf_inverse_DCDM(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestEotf_DCDM(unittest.TestCase): +class TestEotf_DCDM: """ Define :func:`colour.models.rgb.transfer_functions.dcdm.eotf_DCDM` definition unit tests methods. @@ -176,7 +175,3 @@ def test_nan_eotf_DCDM(self): """ eotf_DCDM(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py b/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py index b6f3e934a..71f15e3c8 100644 --- a/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py +++ b/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.dicom_gsdf` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestEotf_inverse_DICOMGSDF(unittest.TestCase): +class TestEotf_inverse_DICOMGSDF: """ Define :func:`colour.models.rgb.transfer_functions.dicom_gsdf.\ eotf_inverse_DICOMGSDF` definition unit tests methods. @@ -118,7 +117,7 @@ def test_nan_eotf_inverse_DICOMGSDF(self): eotf_inverse_DICOMGSDF(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestEotf_DICOMGSDF(unittest.TestCase): +class TestEotf_DICOMGSDF: """ Define :func:`colour.models.rgb.transfer_functions.dicom_gsdf. eotf_DICOMGSDF` definition unit tests methods. @@ -201,7 +200,3 @@ def test_nan_eotf_DICOMGSDF(self): """ eotf_DICOMGSDF(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_dji_d_log.py b/colour/models/rgb/transfer_functions/tests/test_dji_d_log.py index dd1fbe22f..3cd58a211 100644 --- a/colour/models/rgb/transfer_functions/tests/test_dji_d_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_dji_d_log.py @@ -3,7 +3,6 @@ dji_d_log` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestLogEncoding_DJIDLog(unittest.TestCase): +class TestLogEncoding_DJIDLog: """ Define :func:`colour.models.rgb.transfer_functions.dji_d_log.\ log_encoding_DJIDLog` definition unit tests methods. @@ -108,7 +107,7 @@ def test_nan_log_encoding_DLog(self): log_encoding_DJIDLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_DJIDLog(unittest.TestCase): +class TestLogDecoding_DJIDLog: """ Define :func:`colour.models.rgb.transfer_functions.dji_d_log.\ log_decoding_DJIDLog` definition unit tests methods. @@ -183,7 +182,3 @@ def test_nan_log_decoding_DLog(self): """ log_decoding_DJIDLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_exponent.py b/colour/models/rgb/transfer_functions/tests/test_exponent.py index f49a7d9bf..6329f5b63 100644 --- a/colour/models/rgb/transfer_functions/tests/test_exponent.py +++ b/colour/models/rgb/transfer_functions/tests/test_exponent.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.exponent` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestExponentFunctionBasic(unittest.TestCase): +class TestExponentFunctionBasic: """ Define :func:`colour.models.rgb.transfer_functions.exponent.\ exponent_function_basic` definition unit tests methods. @@ -239,7 +238,7 @@ def test_nan_exponent_function_basic(self): exponent_function_basic(case, case) -class TestExponentFunctionMonitorCurve(unittest.TestCase): +class TestExponentFunctionMonitorCurve: """ Define :func:`colour.models.rgb.transfer_functions.exponent.\ exponent_function_monitor_curve` definition unit tests methods. @@ -405,7 +404,3 @@ def test_nan_exponent_function_monitor_curve(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] for case in cases: exponent_function_monitor_curve(case, case, case) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_filmic_pro.py b/colour/models/rgb/transfer_functions/tests/test_filmic_pro.py index 246272fc7..a57437aa1 100644 --- a/colour/models/rgb/transfer_functions/tests/test_filmic_pro.py +++ b/colour/models/rgb/transfer_functions/tests/test_filmic_pro.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.filmic_pro` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestLogEncoding_FilmicPro6(unittest.TestCase): +class TestLogEncoding_FilmicPro6: """ Define :func:`colour.models.rgb.transfer_functions.filmic_pro.\ log_encoding_FilmicPro6` definition unit tests methods. @@ -112,7 +111,7 @@ def test_nan_log_encoding_FilmicPro6(self): log_encoding_FilmicPro6(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_FilmicPro6(unittest.TestCase): +class TestLogDecoding_FilmicPro6: """ Define :func:`colour.models.rgb.transfer_functions.filmic_pro.\ log_decoding_FilmicPro6` definition unit tests methods. @@ -191,7 +190,3 @@ def test_nan_log_decoding_FilmicPro6(self): """ log_decoding_FilmicPro6(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_filmlight_t_log.py b/colour/models/rgb/transfer_functions/tests/test_filmlight_t_log.py index 197722b89..33b461e7f 100644 --- a/colour/models/rgb/transfer_functions/tests/test_filmlight_t_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_filmlight_t_log.py @@ -3,7 +3,6 @@ filmlight_t_log` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestLogEncoding_FilmLightTLog(unittest.TestCase): +class TestLogEncoding_FilmLightTLog: """ Define :func:`colour.models.rgb.transfer_functions.filmlight_t_log.\ log_encoding_FilmLightTLog` definition unit tests methods. @@ -112,7 +111,7 @@ def test_nan_log_encoding_TLog(self): log_encoding_FilmLightTLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_FilmLightTLog(unittest.TestCase): +class TestLogDecoding_FilmLightTLog: """ Define :func:`colour.models.rgb.transfer_functions.filmlight_t_log.\ log_decoding_FilmLightTLog` definition unit tests methods. @@ -195,7 +194,3 @@ def test_nan_log_decoding_TLog(self): """ log_decoding_FilmLightTLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_fujifilm_f_log.py b/colour/models/rgb/transfer_functions/tests/test_fujifilm_f_log.py index 74f718abc..3d41f4868 100644 --- a/colour/models/rgb/transfer_functions/tests/test_fujifilm_f_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_fujifilm_f_log.py @@ -3,7 +3,6 @@ fujifilm_f_log` module. """ -import unittest import numpy as np @@ -31,7 +30,7 @@ ] -class TestLogEncoding_FLog(unittest.TestCase): +class TestLogEncoding_FLog: """ Define :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\ log_encoding_FLog` definition unit tests methods. @@ -134,7 +133,7 @@ def test_nan_log_encoding_FLog(self): log_encoding_FLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_FLog(unittest.TestCase): +class TestLogDecoding_FLog: """ Define :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\ log_decoding_FLog` definition unit tests methods. @@ -237,7 +236,7 @@ def test_nan_log_decoding_FLog(self): log_decoding_FLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogEncoding_FLog2(unittest.TestCase): +class TestLogEncoding_FLog2: """ Define :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\ log_encoding_FLog2` definition unit tests methods. @@ -338,7 +337,7 @@ def test_nan_log_encoding_FLog2(self): log_encoding_FLog2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_FLog2(unittest.TestCase): +class TestLogDecoding_FLog2: """ Define :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\ log_decoding_FLog2` definition unit tests methods. @@ -438,7 +437,3 @@ def test_nan_log_decoding_FLog2(self): """ log_decoding_FLog2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_gamma.py b/colour/models/rgb/transfer_functions/tests/test_gamma.py index 4430b604c..05a7e1cb9 100644 --- a/colour/models/rgb/transfer_functions/tests/test_gamma.py +++ b/colour/models/rgb/transfer_functions/tests/test_gamma.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.gamma` module. """ -import unittest import numpy as np @@ -23,7 +22,7 @@ ] -class TestGammaFunction(unittest.TestCase): +class TestGammaFunction: """ Define :func:`colour.models.rgb.transfer_functions.gamma.gamma_function` definition unit tests methods. @@ -219,7 +218,3 @@ def test_nan_gamma_function(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] gamma_function(cases, cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_gopro.py b/colour/models/rgb/transfer_functions/tests/test_gopro.py index 650758999..1701ae53f 100644 --- a/colour/models/rgb/transfer_functions/tests/test_gopro.py +++ b/colour/models/rgb/transfer_functions/tests/test_gopro.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.gopro` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestLogEncoding_Protune(unittest.TestCase): +class TestLogEncoding_Protune: """ Define :func:`colour.models.rgb.transfer_functions.gopro.\ log_encoding_Protune` definition unit tests methods. @@ -108,7 +107,7 @@ def test_nan_log_encoding_Protune(self): log_encoding_Protune(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_Protune(unittest.TestCase): +class TestLogDecoding_Protune: """ Define :func:`colour.models.rgb.transfer_functions.gopro.\ log_decoding_Protune` definition unit tests methods. @@ -187,7 +186,3 @@ def test_nan_log_decoding_Protune(self): """ log_decoding_Protune(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_1361.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_1361.py index 3581cbb3e..f8d3944fc 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_1361.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_1361.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.itur_bt_1361` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestOetf_BT1361(unittest.TestCase): +class TestOetf_BT1361: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_1361.oetf_BT1361` definition unit tests methods. @@ -108,7 +107,7 @@ def test_nan_oetf_BT1361(self): oetf_BT1361(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOetf_inverse_BT1361(unittest.TestCase): +class TestOetf_inverse_BT1361: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_1361.\ oetf_inverse_BT1361` definition unit tests methods. @@ -199,7 +198,3 @@ def test_nan_oetf_inverse_BT1361(self): """ oetf_inverse_BT1361(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py index f03de0670..c1bf62483 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.itur_bt_1886` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestEotf_inverse_BT1886(unittest.TestCase): +class TestEotf_inverse_BT1886: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_1886.\ eotf_inverse_BT1886` definition unit tests methods. @@ -108,7 +107,7 @@ def test_nan_eotf_inverse_BT1886(self): eotf_inverse_BT1886(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestEotf_BT1886(unittest.TestCase): +class TestEotf_BT1886: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_1886.\ eotf_BT1886` definition unit tests methods. @@ -175,7 +174,3 @@ def test_nan_eotf_BT1886(self): """ eotf_BT1886(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py index 97cab0173..06b8ebd6d 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.itur_bt_2020` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestOetf_BT2020(unittest.TestCase): +class TestOetf_BT2020: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2020.\ oetf_BT2020` definition unit tests methods. @@ -96,7 +95,7 @@ def test_nan_oetf_BT2020(self): oetf_BT2020(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOetf_inverse_BT2020(unittest.TestCase): +class TestOetf_inverse_BT2020: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2020.\ oetf_inverse_BT2020` definition unit tests methods. @@ -175,7 +174,3 @@ def test_nan_oetf_inverse_BT2020(self): """ oetf_inverse_BT2020(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_2100.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_2100.py index c720853f5..f23021bed 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_2100.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_2100.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.itur_bt_2100` module. """ -import unittest import numpy as np @@ -59,7 +58,7 @@ ] -class TestOetf_BT2100_PQ(unittest.TestCase): +class TestOetf_BT2100_PQ: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_BT2100_PQ` definition unit tests methods. @@ -144,7 +143,7 @@ def test_nan_oetf_BT2100_PQ(self): oetf_BT2100_PQ(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOetf_inverse_BT2100_PQ(unittest.TestCase): +class TestOetf_inverse_BT2100_PQ: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_inverse_BT2100_PQ` definition unit tests methods. @@ -229,7 +228,7 @@ def test_nan_oetf_inverse_BT2100_PQ(self): oetf_inverse_BT2100_PQ(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestEotf_BT2100_PQ(unittest.TestCase): +class TestEotf_BT2100_PQ: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_BT2100_PQ` definition unit tests methods. @@ -310,7 +309,7 @@ def test_nan_eotf_BT2100_PQ(self): eotf_BT2100_PQ(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestEotf_inverse_BT2100_PQ(unittest.TestCase): +class TestEotf_inverse_BT2100_PQ: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_inverse_BT2100_PQ` definition unit tests methods. @@ -393,7 +392,7 @@ def test_nan_eotf_inverse_BT2100_PQ(self): eotf_inverse_BT2100_PQ(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOotf_BT2100_PQ(unittest.TestCase): +class TestOotf_BT2100_PQ: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_BT2100_PQ` definition unit tests methods. @@ -476,7 +475,7 @@ def test_nan_ootf_BT2100_PQ(self): ootf_BT2100_PQ(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOotf_inverse_BT2100_PQ(unittest.TestCase): +class TestOotf_inverse_BT2100_PQ: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_inverse_BT2100_PQ` definition unit tests methods. @@ -559,7 +558,7 @@ def test_nan_ootf_inverse_BT2100_PQ(self): ootf_inverse_BT2100_PQ(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestGamma_function_BT2100_HLG(unittest.TestCase): +class TestGamma_function_BT2100_HLG: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ gamma_function_BT2100_HLG` definition unit tests methods. @@ -596,7 +595,7 @@ def test_gamma_function_BT2100_HLG(self): ) -class TestOetf_BT2100_HLG(unittest.TestCase): +class TestOetf_BT2100_HLG: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_BT2100_HLG` definition unit tests methods. @@ -679,7 +678,7 @@ def test_nan_oetf_BT2100_HLG(self): oetf_BT2100_HLG(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOetf_inverse_BT2100_HLG(unittest.TestCase): +class TestOetf_inverse_BT2100_HLG: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_inverse_BT2100_HLG` definition unit tests methods. @@ -762,7 +761,7 @@ def test_nan_oetf_inverse_BT2100_HLG(self): oetf_inverse_BT2100_HLG(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestEotf_BT2100_HLG_1(unittest.TestCase): +class TestEotf_BT2100_HLG_1: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_BT2100_HLG_1` definition unit tests methods. @@ -875,7 +874,7 @@ def test_nan_eotf_BT2100_HLG_1(self): eotf_BT2100_HLG_1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestEotf_BT2100_HLG_2(unittest.TestCase): +class TestEotf_BT2100_HLG_2: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_BT2100_HLG_2` definition unit tests methods. @@ -988,7 +987,7 @@ def test_nan_eotf_BT2100_HLG_2(self): eotf_BT2100_HLG_2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestEotf_inverse_BT2100_HLG_1(unittest.TestCase): +class TestEotf_inverse_BT2100_HLG_1: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_inverse_BT2100_HLG_1` definition unit tests methods. @@ -1101,7 +1100,7 @@ def test_nan_eotf_inverse_BT2100_HLG_1(self): eotf_inverse_BT2100_HLG_1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestEotf_inverse_BT2100_HLG_2(unittest.TestCase): +class TestEotf_inverse_BT2100_HLG_2: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_inverse_BT2100_HLG_2` definition unit tests methods. @@ -1214,7 +1213,7 @@ def test_nan_eotf_inverse_BT2100_HLG_2(self): eotf_inverse_BT2100_HLG_2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOotf_BT2100_HLG_1(unittest.TestCase): +class TestOotf_BT2100_HLG_1: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_BT2100_HLG_1` definition unit tests methods. @@ -1352,7 +1351,7 @@ def test_nan_ootf_BT2100_HLG_1(self): ootf_BT2100_HLG_1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOotf_BT2100_HLG_2(unittest.TestCase): +class TestOotf_BT2100_HLG_2: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_BT2100_HLG_2` definition unit tests methods. @@ -1490,7 +1489,7 @@ def test_nan_ootf_BT2100_HLG_1(self): ootf_BT2100_HLG_1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOotf_inverse_BT2100_HLG_1(unittest.TestCase): +class TestOotf_inverse_BT2100_HLG_1: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_inverse_BT2100_HLG_1` definition unit tests methods. @@ -1628,7 +1627,7 @@ def test_nan_ootf_inverse_BT2100_HLG_1(self): ootf_inverse_BT2100_HLG_1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOotf_inverse_BT2100_HLG_2(unittest.TestCase): +class TestOotf_inverse_BT2100_HLG_2: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_inverse_BT2100_HLG_2` definition unit tests methods. @@ -1764,7 +1763,3 @@ def test_nan_ootf_inverse_BT2100_HLG_2(self): """ ootf_inverse_BT2100_HLG_2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_601.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_601.py index 9589a3ee1..0acf68747 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_601.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_601.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.itur_bt_601` module. """ -import unittest import numpy as np @@ -24,7 +23,7 @@ ] -class TestOetf_BT601(unittest.TestCase): +class TestOetf_BT601: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_601.oetf_BT601` definition unit tests methods. @@ -97,7 +96,7 @@ def test_nan_oetf_BT601(self): oetf_BT601(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOetf_inverse_BT601(unittest.TestCase): +class TestOetf_inverse_BT601: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_601.\ oetf_inverse_BT601` definition unit tests methods. @@ -182,7 +181,3 @@ def test_nan_oetf_inverse_BT601(self): """ oetf_inverse_BT601(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_709.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_709.py index 0e7759b0f..4d2065e20 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_709.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_709.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.itur_bt_709` module. """ -import unittest import numpy as np @@ -24,7 +23,7 @@ ] -class TestOetf_BT709(unittest.TestCase): +class TestOetf_BT709: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_709.oetf_BT709` definition unit tests methods. @@ -97,7 +96,7 @@ def test_nan_oetf_BT709(self): oetf_BT709(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOetf_inverse_BT709(unittest.TestCase): +class TestOetf_inverse_BT709: """ Define :func:`colour.models.rgb.transfer_functions.itur_bt_709.\ oetf_inverse_BT709` definition unit tests methods. @@ -182,7 +181,3 @@ def test_nan_oetf_inverse_BT709(self): """ oetf_inverse_BT709(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_itut_h_273.py b/colour/models/rgb/transfer_functions/tests/test_itut_h_273.py index 05e21ef5f..e6c557763 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itut_h_273.py +++ b/colour/models/rgb/transfer_functions/tests/test_itut_h_273.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.itut_h_273` module. """ -import unittest import numpy as np @@ -39,7 +38,7 @@ ] -class TestOetf_H273_Log(unittest.TestCase): +class TestOetf_H273_Log: """ Define :func:`colour.models.rgb.transfer_functions.itut_h_273. oetf_H273_Log` definition unit tests methods. @@ -114,7 +113,7 @@ def test_nan_oetf_H273_Log(self): oetf_H273_Log(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOetf_inverse_H273_Log(unittest.TestCase): +class TestOetf_inverse_H273_Log: """ Define :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_inverse_H273_Log` definition unit tests methods. @@ -197,7 +196,7 @@ def test_nan_oetf_inverse_H273_Log(self): oetf_inverse_H273_Log(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOetf_H273_LogSqrt(unittest.TestCase): +class TestOetf_H273_LogSqrt: """ Define :func:`colour.models.rgb.transfer_functions.itut_h_273. oetf_H273_LogSqrt` definition unit tests methods. @@ -278,7 +277,7 @@ def test_nan_oetf_H273_LogSqrt(self): oetf_H273_LogSqrt(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOetf_inverse_H273_LogSqrt(unittest.TestCase): +class TestOetf_inverse_H273_LogSqrt: """ Define :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_inverse_H273_LogSqrt` definition unit tests methods. @@ -363,7 +362,7 @@ def test_nan_oetf_inverse_H273_LogSqrt(self): oetf_inverse_H273_LogSqrt(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOetf_H273_IEC61966_2(unittest.TestCase): +class TestOetf_H273_IEC61966_2: """ Define :func:`colour.models.rgb.transfer_functions.itut_h_273. oetf_H273_IEC61966_2` definition unit tests methods. @@ -450,7 +449,7 @@ def test_nan_oetf_H273_IEC61966_2(self): oetf_H273_IEC61966_2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestOetf_inverse_H273_IEC61966_2(unittest.TestCase): +class TestOetf_inverse_H273_IEC61966_2: """ Define :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_inverse_H273_IEC61966_2` definition unit tests methods. @@ -543,7 +542,7 @@ def test_nan_oetf_inverse_H273_IEC61966_2(self): ) -class TestEotf_inverse_H273_ST428_1(unittest.TestCase): +class TestEotf_inverse_H273_ST428_1: """ Define :func:`colour.models.rgb.transfer_functions.itut_h_273. eotf_inverse_H273_ST428_1` definition unit tests methods. @@ -626,7 +625,7 @@ def test_nan_eotf_inverse_H273_ST428_1(self): eotf_inverse_H273_ST428_1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestEotf_H273_ST428_1(unittest.TestCase): +class TestEotf_H273_ST428_1: """ Define :func:`colour.models.rgb.transfer_functions.itut_h_273.\ eotf_H273_ST428_1` definition unit tests methods. @@ -707,7 +706,3 @@ def test_nan_eotf_H273_ST428_1(self): """ eotf_H273_ST428_1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_leica_l_log.py b/colour/models/rgb/transfer_functions/tests/test_leica_l_log.py index ebf30f638..9bd2be28d 100644 --- a/colour/models/rgb/transfer_functions/tests/test_leica_l_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_leica_l_log.py @@ -3,7 +3,6 @@ leica_l_log` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestLogEncoding_LLog(unittest.TestCase): +class TestLogEncoding_LLog: """ Define :func:`colour.models.rgb.transfer_functions.leica_l_log.\ log_encoding_LLog` definition unit tests methods. @@ -130,7 +129,7 @@ def test_nan_log_encoding_LLog(self): log_encoding_LLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_LLog(unittest.TestCase): +class TestLogDecoding_LLog: """ Define :func:`colour.models.rgb.transfer_functions.leica_l_log.\ log_decoding_LLog` definition unit tests methods. @@ -231,7 +230,3 @@ def test_nan_log_decoding_LLog(self): """ log_decoding_LLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_linear.py b/colour/models/rgb/transfer_functions/tests/test_linear.py index d18f7c056..6c867a80c 100644 --- a/colour/models/rgb/transfer_functions/tests/test_linear.py +++ b/colour/models/rgb/transfer_functions/tests/test_linear.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.linear` module. """ -import unittest import numpy as np @@ -23,7 +22,7 @@ ] -class TestLinearFunction(unittest.TestCase): +class TestLinearFunction: """ Define :func:`colour.models.rgb.transfer_functions.linear.\ linear_function` definition unit tests methods. @@ -35,11 +34,11 @@ def test_linear_function(self): linear_function` definition. """ - self.assertEqual(linear_function(0.0), 0.0) + assert linear_function(0.0) == 0.0 - self.assertEqual(linear_function(0.18), 0.18) + assert linear_function(0.18) == 0.18 - self.assertEqual(linear_function(1.0), 1.0) + assert linear_function(1.0) == 1.0 def test_n_dimensional_linear_function(self): """ @@ -77,7 +76,3 @@ def test_nan_linear_function(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] linear_function(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_log.py b/colour/models/rgb/transfer_functions/tests/test_log.py index 1ba2ccc52..28b387f00 100644 --- a/colour/models/rgb/transfer_functions/tests/test_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_log.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.log` module. """ -import unittest import numpy as np @@ -33,7 +32,7 @@ ] -class TestLogarithmFunction_Basic(unittest.TestCase): +class TestLogarithmFunction_Basic: """ Define :func:`colour.models.rgb.transfer_functions.log.\ logarithmic_function_basic` definition unit tests methods. @@ -130,7 +129,7 @@ def test_nan_logarithmic_function_basic(self): logarithmic_function_basic(cases, style) -class TestLogarithmFunction_Quasilog(unittest.TestCase): +class TestLogarithmFunction_Quasilog: """ Define :func:`colour.models.rgb.transfer_functions.log.\ logarithmic_function_quasilog` definition unit tests methods. @@ -271,7 +270,7 @@ def test_nan_logarithmic_function_quasilog(self): logarithmic_function_quasilog(cases, style) -class TestLogarithmFunction_Camera(unittest.TestCase): +class TestLogarithmFunction_Camera: """ Define :func:`colour.models.rgb.transfer_functions.log.\ logarithmic_function_camera` definition unit tests methods. @@ -483,7 +482,7 @@ def test_nan_logarithmic_function_camera(self): logarithmic_function_camera(cases, style) -class TestLogEncoding_Log2(unittest.TestCase): +class TestLogEncoding_Log2: """ Define :func:`colour.models.rgb.transfer_functions.log.\ log_encoding_Log2` definition unit tests methods. @@ -582,7 +581,7 @@ def test_nan_log_encoding_Log2(self): log_encoding_Log2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_Log2(unittest.TestCase): +class TestLogDecoding_Log2: """ Define :func:`colour.models.rgb.transfer_functions.log.\ log_decoding_Log2` definition unit tests methods. @@ -681,7 +680,3 @@ def test_nan_log_decoding_Log2(self): """ log_decoding_Log2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_nikon_n_log.py b/colour/models/rgb/transfer_functions/tests/test_nikon_n_log.py index 55f4b869c..e6f542a83 100644 --- a/colour/models/rgb/transfer_functions/tests/test_nikon_n_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_nikon_n_log.py @@ -3,7 +3,6 @@ nikon_n_log` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestLogEncoding_NLog(unittest.TestCase): +class TestLogEncoding_NLog: """ Define :func:`colour.models.rgb.transfer_functions.nikon_n_log.\ log_encoding_NLog` definition unit tests methods. @@ -130,7 +129,7 @@ def test_nan_log_encoding_NLog(self): log_encoding_NLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_NLog(unittest.TestCase): +class TestLogDecoding_NLog: """ Define :func:`colour.models.rgb.transfer_functions.nikon_n_log.\ log_decoding_NLog` definition unit tests methods. @@ -231,7 +230,3 @@ def test_nan_log_decoding_NLog(self): """ log_decoding_NLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_panalog.py b/colour/models/rgb/transfer_functions/tests/test_panalog.py index f5ebebc3a..782f333d9 100644 --- a/colour/models/rgb/transfer_functions/tests/test_panalog.py +++ b/colour/models/rgb/transfer_functions/tests/test_panalog.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.panalog` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestLogEncoding_Panalog(unittest.TestCase): +class TestLogEncoding_Panalog: """ Define :func:`colour.models.rgb.transfer_functions.panalog.\ log_encoding_Panalog` definition unit tests methods. @@ -112,7 +111,7 @@ def test_nan_log_encoding_Panalog(self): log_encoding_Panalog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_Panalog(unittest.TestCase): +class TestLogDecoding_Panalog: """ Define :func:`colour.models.rgb.transfer_functions.panalog.\ log_decoding_Panalog` definition unit tests methods. @@ -195,7 +194,3 @@ def test_nan_log_decoding_Panalog(self): """ log_decoding_Panalog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py b/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py index 8c8d3bc31..b915cb865 100644 --- a/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py +++ b/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py @@ -3,7 +3,6 @@ panasonic_v_log` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestLogEncoding_VLog(unittest.TestCase): +class TestLogEncoding_VLog: """ Define :func:`colour.models.rgb.transfer_functions.panasonic_v_log.\ log_encoding_VLog` definition unit tests methods. @@ -128,7 +127,7 @@ def test_nan_log_encoding_VLog(self): log_encoding_VLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_VLog(unittest.TestCase): +class TestLogDecoding_VLog: """ Define :func:`colour.models.rgb.transfer_functions.panasonic_v_log.\ log_decoding_VLog` definition unit tests methods. @@ -227,7 +226,3 @@ def test_nan_log_decoding_VLog(self): """ log_decoding_VLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_pivoted_log.py b/colour/models/rgb/transfer_functions/tests/test_pivoted_log.py index ab621d869..10416d467 100644 --- a/colour/models/rgb/transfer_functions/tests/test_pivoted_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_pivoted_log.py @@ -3,7 +3,6 @@ pivoted_log` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestLogEncoding_PivotedLog(unittest.TestCase): +class TestLogEncoding_PivotedLog: """ Define :func:`colour.models.rgb.transfer_functions.pivoted_log.\ log_encoding_PivotedLog` definition unit tests methods. @@ -112,7 +111,7 @@ def test_nan_log_encoding_PivotedLog(self): log_encoding_PivotedLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_PivotedLog(unittest.TestCase): +class TestLogDecoding_PivotedLog: """ Define :func:`colour.models.rgb.transfer_functions.pivoted_log.\ log_decoding_PivotedLog` definition unit tests methods. @@ -195,7 +194,3 @@ def test_nan_log_decoding_PivotedLog(self): """ log_decoding_PivotedLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_red.py b/colour/models/rgb/transfer_functions/tests/test_red.py index 901bfb31b..3e8de1374 100644 --- a/colour/models/rgb/transfer_functions/tests/test_red.py +++ b/colour/models/rgb/transfer_functions/tests/test_red.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.red` module. """ -import unittest import numpy as np @@ -49,7 +48,7 @@ ] -class TestLogEncoding_REDLog(unittest.TestCase): +class TestLogEncoding_REDLog: """ Define :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_REDLog` definition unit tests methods. @@ -130,7 +129,7 @@ def test_nan_log_encoding_REDLog(self): log_encoding_REDLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_REDLog(unittest.TestCase): +class TestLogDecoding_REDLog: """ Define :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_REDLog` definition unit tests methods. @@ -211,7 +210,7 @@ def test_nan_log_decoding_REDLog(self): log_decoding_REDLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogEncoding_REDLogFilm(unittest.TestCase): +class TestLogEncoding_REDLogFilm: """ Define :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_REDLogFilm` definition unit tests methods. @@ -296,7 +295,7 @@ def test_nan_log_encoding_REDLogFilm(self): log_encoding_REDLogFilm(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_REDLogFilm(unittest.TestCase): +class TestLogDecoding_REDLogFilm: """ Define :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_REDLogFilm` definition unit tests methods. @@ -381,7 +380,7 @@ def test_nan_log_decoding_REDLogFilm(self): log_decoding_REDLogFilm(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogEncoding_Log3G10_v1(unittest.TestCase): +class TestLogEncoding_Log3G10_v1: """ Define :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G10_v1` definition unit tests methods. @@ -464,7 +463,7 @@ def test_nan_log_encoding_Log3G10_v1(self): log_encoding_Log3G10_v1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_Log3G10_v1(unittest.TestCase): +class TestLogDecoding_Log3G10_v1: """ Define :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G10_v1` definition unit tests methods. @@ -547,7 +546,7 @@ def test_nan_log_decoding_Log3G10_v1(self): log_decoding_Log3G10_v1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogEncoding_Log3G10_v2(unittest.TestCase): +class TestLogEncoding_Log3G10_v2: """ Define :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G10_v2` definition unit tests methods. @@ -632,7 +631,7 @@ def test_nan_log_encoding_Log3G10_v2(self): log_encoding_Log3G10_v2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_Log3G10_v2(unittest.TestCase): +class TestLogDecoding_Log3G10_v2: """ Define :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G10_v2` definition unit tests methods. @@ -717,7 +716,7 @@ def test_nan_log_decoding_Log3G10_v2(self): log_decoding_Log3G10_v2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogEncoding_Log3G10_v3(unittest.TestCase): +class TestLogEncoding_Log3G10_v3: """ Define :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G10_v3` definition unit tests methods. @@ -802,7 +801,7 @@ def test_nan_log_encoding_Log3G10_v3(self): log_encoding_Log3G10_v3(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_Log3G10_v3(unittest.TestCase): +class TestLogDecoding_Log3G10_v3: """ Define :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G10_v3` definition unit tests methods. @@ -887,7 +886,7 @@ def test_nan_log_decoding_Log3G10_v3(self): log_decoding_Log3G10_v3(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogEncoding_Log3G12(unittest.TestCase): +class TestLogEncoding_Log3G12: """ Define :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G12` definition unit tests methods. @@ -976,7 +975,7 @@ def test_nan_log_encoding_Log3G12(self): log_encoding_Log3G12(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_Log3G12(unittest.TestCase): +class TestLogDecoding_Log3G12: """ Define :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G12` definition unit tests methods. @@ -1063,7 +1062,3 @@ def test_nan_log_decoding_Log3G12(self): """ log_decoding_Log3G12(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_rimm_romm_rgb.py b/colour/models/rgb/transfer_functions/tests/test_rimm_romm_rgb.py index 8097339af..4b2baa75b 100644 --- a/colour/models/rgb/transfer_functions/tests/test_rimm_romm_rgb.py +++ b/colour/models/rgb/transfer_functions/tests/test_rimm_romm_rgb.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.rimm_romm_rgb` module. """ -import unittest import numpy as np @@ -35,7 +34,7 @@ ] -class TestCctfEncoding_ROMMRGB(unittest.TestCase): +class TestCctfEncoding_ROMMRGB: """ Define :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ cctf_encoding_ROMMRGB` definition unit tests methods. @@ -61,9 +60,9 @@ def test_cctf_encoding_ROMMRGB(self): cctf_encoding_ROMMRGB(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - self.assertEqual(cctf_encoding_ROMMRGB(0.18, out_int=True), 98) + assert cctf_encoding_ROMMRGB(0.18, out_int=True) == 98 - self.assertEqual(cctf_encoding_ROMMRGB(0.18, bit_depth=12, out_int=True), 1579) + assert cctf_encoding_ROMMRGB(0.18, bit_depth=12, out_int=True) == 1579 def test_n_dimensional_cctf_encoding_ROMMRGB(self): """ @@ -120,7 +119,7 @@ def test_nan_cctf_encoding_ROMMRGB(self): cctf_encoding_ROMMRGB(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestCctfDecoding_ROMMRGB(unittest.TestCase): +class TestCctfDecoding_ROMMRGB: """ Define :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb. cctf_decoding_ROMMRGB` definition unit tests methods. @@ -213,7 +212,7 @@ def test_nan_cctf_decoding_ROMMRGB(self): cctf_decoding_ROMMRGB(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestCctfEncoding_RIMMRGB(unittest.TestCase): +class TestCctfEncoding_RIMMRGB: """ Define :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ cctf_encoding_RIMMRGB` definition unit tests methods. @@ -241,9 +240,9 @@ def test_cctf_encoding_RIMMRGB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual(cctf_encoding_RIMMRGB(0.18, out_int=True), 74) + assert cctf_encoding_RIMMRGB(0.18, out_int=True) == 74 - self.assertEqual(cctf_encoding_RIMMRGB(0.18, bit_depth=12, out_int=True), 1194) + assert cctf_encoding_RIMMRGB(0.18, bit_depth=12, out_int=True) == 1194 def test_n_dimensional_cctf_encoding_RIMMRGB(self): """ @@ -300,7 +299,7 @@ def test_nan_cctf_encoding_RIMMRGB(self): cctf_encoding_RIMMRGB(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestCctfDecoding_RIMMRGB(unittest.TestCase): +class TestCctfDecoding_RIMMRGB: """ Define :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb. cctf_decoding_RIMMRGB` definition unit tests methods. @@ -395,7 +394,7 @@ def test_nan_cctf_decoding_RIMMRGB(self): cctf_decoding_RIMMRGB(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLog_encoding_ERIMMRGB(unittest.TestCase): +class TestLog_encoding_ERIMMRGB: """ Define :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ log_encoding_ERIMMRGB` definition unit tests methods. @@ -423,9 +422,9 @@ def test_log_encoding_ERIMMRGB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual(log_encoding_ERIMMRGB(0.18, out_int=True), 105) + assert log_encoding_ERIMMRGB(0.18, out_int=True) == 105 - self.assertEqual(log_encoding_ERIMMRGB(0.18, bit_depth=12, out_int=True), 1679) + assert log_encoding_ERIMMRGB(0.18, bit_depth=12, out_int=True) == 1679 def test_n_dimensional_log_encoding_ERIMMRGB(self): """ @@ -482,7 +481,7 @@ def test_nan_log_encoding_ERIMMRGB(self): log_encoding_ERIMMRGB(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLog_decoding_ERIMMRGB(unittest.TestCase): +class TestLog_decoding_ERIMMRGB: """ Define :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb. log_decoding_ERIMMRGB` definition unit tests methods. @@ -575,7 +574,3 @@ def test_nan_log_decoding_ERIMMRGB(self): """ log_decoding_ERIMMRGB(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_smpte_240m.py b/colour/models/rgb/transfer_functions/tests/test_smpte_240m.py index d23b9f541..beb8fbf6f 100644 --- a/colour/models/rgb/transfer_functions/tests/test_smpte_240m.py +++ b/colour/models/rgb/transfer_functions/tests/test_smpte_240m.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.smpte_240m` module. """ -import unittest import numpy as np @@ -24,7 +23,7 @@ ] -class TestOetf_SMPTE240M(unittest.TestCase): +class TestOetf_SMPTE240M: """ Define :func:`colour.models.rgb.transfer_functions.smpte_240m.\ oetf_SMPTE240M` definition unit tests methods. @@ -111,7 +110,7 @@ def test_nan_oetf_SMPTE240M(self): oetf_SMPTE240M(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestEotf_SMPTE240M(unittest.TestCase): +class TestEotf_SMPTE240M: """ Define :func:`colour.models.rgb.transfer_functions.smpte_240m.\ eotf_SMPTE240M` definition unit tests methods. @@ -196,7 +195,3 @@ def test_nan_eotf_SMPTE240M(self): """ eotf_SMPTE240M(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_sony.py b/colour/models/rgb/transfer_functions/tests/test_sony.py index 3b247b3f0..184505083 100644 --- a/colour/models/rgb/transfer_functions/tests/test_sony.py +++ b/colour/models/rgb/transfer_functions/tests/test_sony.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.sony` module. """ -import unittest import numpy as np @@ -35,7 +34,7 @@ ] -class TestLogEncoding_SLog(unittest.TestCase): +class TestLogEncoding_SLog: """ Define :func:`colour.models.rgb.transfer_functions.sony.\ log_encoding_SLog` definition unit tests methods. @@ -138,7 +137,7 @@ def test_nan_log_encoding_SLog(self): log_encoding_SLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_SLog(unittest.TestCase): +class TestLogDecoding_SLog: """ Define :func:`colour.models.rgb.transfer_functions.sony.\ log_decoding_SLog` definition unit tests methods. @@ -241,7 +240,7 @@ def test_nan_log_decoding_SLog(self): log_decoding_SLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogEncoding_SLog2(unittest.TestCase): +class TestLogEncoding_SLog2: """ Define :func:`colour.models.rgb.transfer_functions.sony.\ log_encoding_SLog2` definition unit tests methods. @@ -344,7 +343,7 @@ def test_nan_log_encoding_SLog2(self): log_encoding_SLog2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_SLog2(unittest.TestCase): +class TestLogDecoding_SLog2: """ Define :func:`colour.models.rgb.transfer_functions.sony.\ log_decoding_SLog2` definition unit tests methods. @@ -447,7 +446,7 @@ def test_nan_log_decoding_SLog2(self): log_decoding_SLog2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogEncoding_SLog3(unittest.TestCase): +class TestLogEncoding_SLog3: """ Define :func:`colour.models.rgb.transfer_functions.sony.\ log_encoding_SLog3` definition unit tests methods. @@ -550,7 +549,7 @@ def test_nan_log_encoding_SLog3(self): log_encoding_SLog3(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_SLog3(unittest.TestCase): +class TestLogDecoding_SLog3: """ Define :func:`colour.models.rgb.transfer_functions.sony.\ log_decoding_SLog3` definition unit tests methods. @@ -651,7 +650,3 @@ def test_nan_log_decoding_SLog3(self): """ log_decoding_SLog3(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_srgb.py b/colour/models/rgb/transfer_functions/tests/test_srgb.py index 22b082ad8..c3425ea90 100644 --- a/colour/models/rgb/transfer_functions/tests/test_srgb.py +++ b/colour/models/rgb/transfer_functions/tests/test_srgb.py @@ -3,7 +3,6 @@ module. """ -import unittest import numpy as np @@ -24,7 +23,7 @@ ] -class TestEotf_inverse_sRGB(unittest.TestCase): +class TestEotf_inverse_sRGB: """ Define :func:`colour.models.rgb.transfer_functions.sRGB.eotf_inverse_sRGB` definition unit tests methods. @@ -105,7 +104,7 @@ def test_nan_eotf_inverse_sRGB(self): eotf_inverse_sRGB(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestEotf_sRGB(unittest.TestCase): +class TestEotf_sRGB: """ Define :func:`colour.models.rgb.transfer_functions.sRGB.eotf_sRGB` definition unit tests methods. @@ -172,7 +171,3 @@ def test_nan_eotf_sRGB(self): """ eotf_sRGB(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_st_2084.py b/colour/models/rgb/transfer_functions/tests/test_st_2084.py index 90c6088b2..49e21f83b 100644 --- a/colour/models/rgb/transfer_functions/tests/test_st_2084.py +++ b/colour/models/rgb/transfer_functions/tests/test_st_2084.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.st_2084` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestEotf_inverse_ST2084(unittest.TestCase): +class TestEotf_inverse_ST2084: """ Define :func:`colour.models.rgb.transfer_functions.st_2084.\ eotf_inverse_ST2084` definition unit tests methods. @@ -116,7 +115,7 @@ def test_nan_eotf_inverse_ST2084(self): eotf_inverse_ST2084(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestEotf_ST2084(unittest.TestCase): +class TestEotf_ST2084: """ Define :func:`colour.models.rgb.transfer_functions.st_2084.eotf_ST2084` definition unit tests methods. @@ -189,7 +188,3 @@ def test_nan_eotf_ST2084(self): """ eotf_ST2084(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/rgb/transfer_functions/tests/test_viper_log.py b/colour/models/rgb/transfer_functions/tests/test_viper_log.py index abe23ed1a..df300893e 100644 --- a/colour/models/rgb/transfer_functions/tests/test_viper_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_viper_log.py @@ -3,7 +3,6 @@ :mod:`colour.models.rgb.transfer_functions.viper_log` module. """ -import unittest import numpy as np @@ -27,7 +26,7 @@ ] -class TestLogEncoding_ViperLog(unittest.TestCase): +class TestLogEncoding_ViperLog: """ Define :func:`colour.models.rgb.transfer_functions.viper_log.\ log_encoding_ViperLog` definition unit tests methods. @@ -108,7 +107,7 @@ def test_nan_log_encoding_ViperLog(self): log_encoding_ViperLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestLogDecoding_ViperLog(unittest.TestCase): +class TestLogDecoding_ViperLog: """ Define :func:`colour.models.rgb.transfer_functions.viper_log.\ log_decoding_ViperLog` definition unit tests methods. @@ -187,7 +186,3 @@ def test_nan_log_decoding_ViperLog(self): """ log_decoding_ViperLog(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_cam02_ucs.py b/colour/models/tests/test_cam02_ucs.py index e7a423bcf..c641742ef 100644 --- a/colour/models/tests/test_cam02_ucs.py +++ b/colour/models/tests/test_cam02_ucs.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.cam02_ucs` module.""" -import unittest from itertools import product import numpy as np @@ -50,13 +49,13 @@ ] -class TestJMh_CIECAM02_to_UCS_Luo2006(unittest.TestCase): +class TestJMh_CIECAM02_to_UCS_Luo2006: """ Define :func:`colour.models.cam02_ucs.JMh_CIECAM02_to_UCS_Luo2006` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" XYZ = np.array([19.01, 20.00, 21.78]) @@ -183,7 +182,7 @@ def test_nan_JMh_CIECAM02_to_UCS_Luo2006(self): JMh_CIECAM02_to_UCS_Luo2006(cases, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"]) -class TestUCS_Luo2006_to_JMh_CIECAM02(unittest.TestCase): +class TestUCS_Luo2006_to_JMh_CIECAM02: """ Define :func:`colour.models.cam02_ucs.UCS_Luo2006_to_JMh_CIECAM02` definition unit tests methods. @@ -311,7 +310,7 @@ def test_nan_UCS_Luo2006_to_JMh_CIECAM02(self): UCS_Luo2006_to_JMh_CIECAM02(cases, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"]) -class TestXYZ_to_UCS_Luo2006(unittest.TestCase): +class TestXYZ_to_UCS_Luo2006: """ Define :func:`colour.models.cam02_ucs.XYZ_to_UCS_Luo2006` definition unit tests methods. @@ -434,7 +433,7 @@ def test_nan_XYZ_to_UCS_Luo2006(self): XYZ_to_UCS_Luo2006(cases, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"]) -class TestUCS_Luo2006_to_XYZ(unittest.TestCase): +class TestUCS_Luo2006_to_XYZ: """ Define :func:`colour.models.cam02_ucs.UCS_Luo2006_to_XYZ` definition unit tests methods. @@ -559,7 +558,3 @@ def test_nan_UCS_Luo2006_to_XYZ(self): UCS_Luo2006_to_XYZ(case, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"]) except ValueError as error: attest("CAM_Specification_CIECAM02" in str(error)) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_cam16_ucs.py b/colour/models/tests/test_cam16_ucs.py index 93988d37f..8b3b50f4c 100644 --- a/colour/models/tests/test_cam16_ucs.py +++ b/colour/models/tests/test_cam16_ucs.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.cam16_ucs` module.""" -import unittest from colour.models.tests.test_cam02_ucs import ( TestJMh_CIECAM02_to_UCS_Luo2006, @@ -63,7 +62,3 @@ class TestUCS_Li2017_to_XYZ(TestUCS_Luo2006_to_XYZ): Define :func:`colour.models.cam16_ucs.UCS_Li2017_to_XYZ` definition unit tests methods. """ - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_cie_lab.py b/colour/models/tests/test_cie_lab.py index 7da98a5f0..2d39a0257 100644 --- a/colour/models/tests/test_cie_lab.py +++ b/colour/models/tests/test_cie_lab.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.cie_lab` module.""" -import unittest from itertools import product import numpy as np @@ -25,7 +24,7 @@ ] -class TestXYZ_to_Lab(unittest.TestCase): +class TestXYZ_to_Lab: """ Define :func:`colour.models.cie_lab.XYZ_to_Lab` definition unit tests methods. @@ -135,7 +134,7 @@ def test_nan_XYZ_to_Lab(self): XYZ_to_Lab(cases, cases[..., 0:2]) -class TestLab_to_XYZ(unittest.TestCase): +class TestLab_to_XYZ: """ Define :func:`colour.models.cie_lab.Lab_to_XYZ` definition unit tests methods. @@ -245,7 +244,7 @@ def test_nan_Lab_to_XYZ(self): Lab_to_XYZ(cases, cases[..., 0:2]) -class TestLab_to_LCHab(unittest.TestCase): +class TestLab_to_LCHab: """ Define :func:`colour.models.cie_lab.Lab_to_LCHab` definition unit tests methods. @@ -327,7 +326,7 @@ def test_nan_Lab_to_LCHab(self): Lab_to_LCHab(cases) -class TestLCHab_to_Lab(unittest.TestCase): +class TestLCHab_to_Lab: """ Define :func:`colour.models.cie_lab.LCHab_to_Lab` definition unit tests methods. @@ -407,7 +406,3 @@ def test_nan_LCHab_to_Lab(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) LCHab_to_Lab(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_cie_luv.py b/colour/models/tests/test_cie_luv.py index 78b29691e..d3feb6612 100644 --- a/colour/models/tests/test_cie_luv.py +++ b/colour/models/tests/test_cie_luv.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.cie_luv` module.""" -import unittest from itertools import product import numpy as np @@ -42,7 +41,7 @@ ] -class TestXYZ_to_Luv(unittest.TestCase): +class TestXYZ_to_Luv: """ Define :func:`colour.models.cie_luv.XYZ_to_Luv` definition unit tests methods. @@ -152,7 +151,7 @@ def test_nan_XYZ_to_Luv(self): XYZ_to_Luv(cases, cases[..., 0:2]) -class TestLuv_to_XYZ(unittest.TestCase): +class TestLuv_to_XYZ: """ Define :func:`colour.models.cie_luv.Luv_to_XYZ` definition unit tests methods. @@ -262,7 +261,7 @@ def test_nan_Luv_to_XYZ(self): Luv_to_XYZ(cases, cases[..., 0:2]) -class TestLuv_to_uv(unittest.TestCase): +class TestLuv_to_uv: """ Define :func:`colour.models.cie_luv.Luv_to_uv` definition unit tests methods. @@ -372,7 +371,7 @@ def test_nan_Luv_to_uv(self): Luv_to_uv(cases, cases[..., 0:2]) -class Testuv_to_Luv(unittest.TestCase): +class Testuv_to_Luv: """ Define :func:`colour.models.cie_luv.uv_to_Luv` definition unit tests methods. @@ -489,7 +488,7 @@ def test_nan_uv_to_Luv(self): uv_to_Luv(cases, cases[..., 0:2]) -class TestLuv_uv_to_xy(unittest.TestCase): +class TestLuv_uv_to_xy: """ Define :func:`colour.models.cie_luv.Luv_uv_to_xy` definition unit tests methods. @@ -545,7 +544,7 @@ def test_nan_Luv_uv_to_xy(self): Luv_uv_to_xy(cases) -class TestXy_to_Luv_uv(unittest.TestCase): +class TestXy_to_Luv_uv: """ Define :func:`colour.models.cie_luv.xy_to_Luv_uv` definition unit tests methods. @@ -601,7 +600,7 @@ def test_nan_xy_to_Luv_uv(self): xy_to_Luv_uv(cases) -class TestLuv_to_LCHuv(unittest.TestCase): +class TestLuv_to_LCHuv: """ Define :func:`colour.models.cie_luv.Luv_to_LCHuv` definition unit tests methods. @@ -683,7 +682,7 @@ def test_nan_Luv_to_LCHuv(self): Luv_to_LCHuv(cases) -class TestLCHuv_to_Luv(unittest.TestCase): +class TestLCHuv_to_Luv: """ Define :func:`colour.models.cie_luv.LCHuv_to_Luv` definition unit tests methods. @@ -765,7 +764,7 @@ def test_nan_LCHuv_to_Luv(self): LCHuv_to_Luv(cases) -class TestXYZ_to_CIE1976UCS(unittest.TestCase): +class TestXYZ_to_CIE1976UCS: """ Define :func:`colour.models.cie_luv.XYZ_to_CIE1976UCS` definition unit tests methods. @@ -878,7 +877,7 @@ def test_nan_XYZ_to_CIE1976UCS(self): XYZ_to_CIE1976UCS(cases, cases[..., 0:2]) -class TestCIE1976UCS_to_XYZ(unittest.TestCase): +class TestCIE1976UCS_to_XYZ: """ Define :func:`colour.models.cie_luv.CIE1976UCS_to_XYZ` definition unit tests methods. @@ -989,7 +988,3 @@ def test_nan_CIE1976UCS_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) CIE1976UCS_to_XYZ(cases, cases[..., 0:2]) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_cie_ucs.py b/colour/models/tests/test_cie_ucs.py index 798920e7a..4f0a05f45 100644 --- a/colour/models/tests/test_cie_ucs.py +++ b/colour/models/tests/test_cie_ucs.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.cie_ucs` module.""" -import unittest from itertools import product import numpy as np @@ -38,7 +37,7 @@ ] -class TestXYZ_to_UCS(unittest.TestCase): +class TestXYZ_to_UCS: """ Define :func:`colour.models.cie_ucs.XYZ_to_UCS` definition unit tests methods. @@ -109,7 +108,7 @@ def test_nan_XYZ_to_UCS(self): XYZ_to_UCS(cases) -class TestUCS_to_XYZ(unittest.TestCase): +class TestUCS_to_XYZ: """ Define :func:`colour.models.cie_ucs.UCS_to_XYZ` definition unit tests methods. @@ -180,7 +179,7 @@ def test_nan_UCS_to_XYZ(self): UCS_to_XYZ(cases) -class TestUCS_to_uv(unittest.TestCase): +class TestUCS_to_uv: """ Define :func:`colour.models.cie_ucs.UCS_to_uv` definition unit tests methods. @@ -249,7 +248,7 @@ def test_nan_UCS_to_uv(self): UCS_to_uv(cases) -class Testuv_to_UCS(unittest.TestCase): +class Testuv_to_UCS: """ Define :func:`colour.models.cie_ucs.uv_to_UCS` definition unit tests methods. @@ -327,7 +326,7 @@ def test_nan_uv_to_UCS(self): uv_to_UCS(cases) -class TestUCS_uv_to_xy(unittest.TestCase): +class TestUCS_uv_to_xy: """ Define :func:`colour.models.cie_ucs.UCS_uv_to_xy` definition unit tests methods. @@ -383,7 +382,7 @@ def test_nan_UCS_uv_to_xy(self): UCS_uv_to_xy(cases) -class TestXy_to_UCS_uv(unittest.TestCase): +class TestXy_to_UCS_uv: """ Define :func:`colour.models.cie_ucs.xy_to_UCS_uv` definition unit tests methods. @@ -439,7 +438,7 @@ def test_nan_xy_to_UCS_uv(self): xy_to_UCS_uv(cases) -class TestXYZ_to_CIE1960UCS(unittest.TestCase): +class TestXYZ_to_CIE1960UCS: """ Define :func:`colour.models.cie_ucs.XYZ_to_CIE1960UCS` definition unit tests methods. @@ -517,7 +516,7 @@ def test_nan_XYZ_to_CIE1960UCS(self): XYZ_to_CIE1960UCS(cases) -class TestCIE1960UCS_to_XYZ(unittest.TestCase): +class TestCIE1960UCS_to_XYZ: """ Define :func:`colour.models.cie_ucs.CIE1960UCS_to_XYZ` definition unit tests methods. @@ -593,7 +592,3 @@ def test_nan_CIE1960UCS_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) CIE1960UCS_to_XYZ(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_cie_uvw.py b/colour/models/tests/test_cie_uvw.py index 60cf4142b..2ebc1c49a 100644 --- a/colour/models/tests/test_cie_uvw.py +++ b/colour/models/tests/test_cie_uvw.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.cie_uvw` module.""" -import unittest from itertools import product import numpy as np @@ -23,7 +22,7 @@ ] -class TestXYZ_to_UVW(unittest.TestCase): +class TestXYZ_to_UVW: """ Define :func:`colour.models.cie_uvw.XYZ_to_UVW` definition unit tests methods. @@ -133,7 +132,7 @@ def test_nan_XYZ_to_UVW(self): XYZ_to_UVW(cases, cases[..., 0:2]) -class TestUVW_to_XYZ(unittest.TestCase): +class TestUVW_to_XYZ: """ Define :func:`colour.models.cie_uvw.UVW_to_XYZ` definition unit tests methods. @@ -241,7 +240,3 @@ def test_nan_UVW_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) UVW_to_XYZ(cases, cases[..., 0:2]) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_cie_xyy.py b/colour/models/tests/test_cie_xyy.py index 79b12790c..636a39e5a 100644 --- a/colour/models/tests/test_cie_xyy.py +++ b/colour/models/tests/test_cie_xyy.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.cie_xyy` module.""" -import unittest from itertools import product import numpy as np @@ -34,7 +33,7 @@ ] -class TestXYZ_to_xyY(unittest.TestCase): +class TestXYZ_to_xyY: """ Define :func:`colour.models.cie_xyy.XYZ_to_xyY` definition unit tests methods. @@ -137,7 +136,7 @@ def test_nan_XYZ_to_xyY(self): XYZ_to_xyY(cases) -class TestxyY_to_XYZ(unittest.TestCase): +class TestxyY_to_XYZ: """ Define :func:`colour.models.cie_xyy.xyY_to_XYZ` definition unit tests methods. @@ -240,7 +239,7 @@ def test_nan_xyY_to_XYZ(self): xyY_to_XYZ(cases) -class TestxyY_to_xy(unittest.TestCase): +class TestxyY_to_xy: """ Define :func:`colour.models.cie_xyy.xyY_to_xy` definition unit tests methods. @@ -323,7 +322,7 @@ def test_nan_xyY_to_xy(self): xyY_to_xy(cases) -class Testxy_to_xyY(unittest.TestCase): +class Testxy_to_xyY: """ Define :func:`colour.models.cie_xyy.xy_to_xyY` definition unit tests methods. @@ -416,7 +415,7 @@ def test_nan_xy_to_xyY(self): xy_to_xyY(cases) -class TestXYZ_to_xy(unittest.TestCase): +class TestXYZ_to_xy: """ Define :func:`colour.models.cie_xyy.XYZ_to_xy` definition unit tests methods. @@ -493,7 +492,7 @@ def test_nan_XYZ_to_xy(self): XYZ_to_xy(cases) -class Testxy_to_XYZ(unittest.TestCase): +class Testxy_to_XYZ: """ Define :func:`colour.models.cie_xyy.xy_to_XYZ` definition unit tests methods. @@ -574,7 +573,3 @@ def test_nan_xy_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=2)))) xy_to_XYZ(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_common.py b/colour/models/tests/test_common.py index 95dcb1b8a..e18974da0 100644 --- a/colour/models/tests/test_common.py +++ b/colour/models/tests/test_common.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.common` module.""" -import unittest from itertools import product import numpy as np @@ -25,7 +24,7 @@ ] -class TestJab_to_JCh(unittest.TestCase): +class TestJab_to_JCh: """ Define :func:`colour.models.common.Jab_to_JCh` definition unit tests methods. @@ -104,7 +103,7 @@ def test_nan_Jab_to_JCh(self): Jab_to_JCh(cases) -class TestJCh_to_Jab(unittest.TestCase): +class TestJCh_to_Jab: """ Define :func:`colour.models.common.JCh_to_Jab` definition unit tests methods. @@ -183,10 +182,10 @@ def test_nan_JCh_to_Jab(self): JCh_to_Jab(cases) -class TestXYZ_to_Iab(unittest.TestCase): +class TestXYZ_to_Iab: """Define :func:`colour.models.common.XYZ_to_Iab` definition unit tests methods.""" - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self.LMS_to_LMS_p = lambda x: x**0.43 @@ -298,13 +297,13 @@ def test_nan_XYZ_to_Iab(self): XYZ_to_Iab(cases, self.LMS_to_LMS_p, self.M_XYZ_to_LMS, self.M_LMS_p_to_Iab) -class TestIab_to_XYZ(unittest.TestCase): +class TestIab_to_XYZ: """ Define :func:`colour.models.common.Iab_to_XYZ` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self.LMS_p_to_LMS = lambda x: x ** (1 / 0.43) @@ -418,7 +417,3 @@ def test_nan_Iab_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) Iab_to_XYZ(cases, self.LMS_p_to_LMS, self.M_Iab_to_LMS_p, self.M_LMS_to_XYZ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_din99.py b/colour/models/tests/test_din99.py index 9a8147cb3..f6cb86f93 100644 --- a/colour/models/tests/test_din99.py +++ b/colour/models/tests/test_din99.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.din99` module.""" -import unittest from itertools import product import numpy as np @@ -30,7 +29,7 @@ ] -class TestLab_to_DIN99(unittest.TestCase): +class TestLab_to_DIN99: """ Define :func:`colour.models.din99.Lab_to_DIN99` definition unit tests methods. @@ -153,7 +152,7 @@ def test_nan_Lab_to_DIN99(self): Lab_to_DIN99(cases, method="DIN99d") -class TestDIN99_to_Lab(unittest.TestCase): +class TestDIN99_to_Lab: """ Define :func:`colour.models.din99.DIN99_to_Lab` definition unit tests methods. @@ -276,7 +275,7 @@ def test_nan_DIN99_to_Lab(self): DIN99_to_Lab(cases, method="DIN99d") -class TestXYZ_to_DIN99(unittest.TestCase): +class TestXYZ_to_DIN99: """ Define :func:`colour.models.din99.XYZ_to_DIN99` definition unit tests methods. @@ -359,7 +358,7 @@ def test_nan_XYZ_to_DIN99(self): XYZ_to_DIN99(cases) -class TestDIN99_to_XYZ(unittest.TestCase): +class TestDIN99_to_XYZ: """ Define :func:`colour.models.din99.DIN99_to_XYZ` definition unit tests methods. @@ -441,7 +440,3 @@ def test_nan_DIN99_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) DIN99_to_XYZ(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_hdr_cie_lab.py b/colour/models/tests/test_hdr_cie_lab.py index 764b5a64e..a3b0cb1f9 100644 --- a/colour/models/tests/test_hdr_cie_lab.py +++ b/colour/models/tests/test_hdr_cie_lab.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.hdr_cie_lab` module.""" -import unittest from itertools import product import numpy as np @@ -25,7 +24,7 @@ ] -class TestExponent_hdr_CIELab(unittest.TestCase): +class TestExponent_hdr_CIELab: """ Define :func:`colour.models.hdr_cie_lab.exponent_hdr_CIELab` definition unit tests methods. @@ -128,7 +127,7 @@ def test_nan_exponent_hdr_CIELab(self): exponent_hdr_CIELab(cases, cases) -class TestXYZ_to_hdr_CIELab(unittest.TestCase): +class TestXYZ_to_hdr_CIELab: """ Define :func:`colour.models.hdr_cie_lab.XYZ_to_hdr_CIELab` definition unit tests methods. @@ -251,7 +250,7 @@ def test_nan_XYZ_to_hdr_CIELab(self): XYZ_to_hdr_CIELab(cases, cases[..., 0:2], cases[..., 0], cases[..., 0]) -class TestHdr_CIELab_to_XYZ(unittest.TestCase): +class TestHdr_CIELab_to_XYZ: """ Define :func:`colour.models.hdr_cie_lab.hdr_CIELab_to_XYZ` definition unit tests methods. @@ -374,7 +373,3 @@ def test_nan_hdr_CIELab_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) hdr_CIELab_to_XYZ(cases, cases[..., 0:2], cases[..., 0], cases[..., 0]) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_hdr_ipt.py b/colour/models/tests/test_hdr_ipt.py index 4daf2d636..7cd0cf382 100644 --- a/colour/models/tests/test_hdr_ipt.py +++ b/colour/models/tests/test_hdr_ipt.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.hdr_ipt` module.""" -import unittest from itertools import product import numpy as np @@ -25,7 +24,7 @@ ] -class TestExponent_hdr_IPT(unittest.TestCase): +class TestExponent_hdr_IPT: """ Define :func:`colour.models.hdr_ipt.exponent_hdr_IPT` definition unit tests methods. @@ -125,7 +124,7 @@ def test_nan_exponent_hdr_IPT(self): exponent_hdr_IPT(cases, cases) -class TestXYZ_to_hdr_IPT(unittest.TestCase): +class TestXYZ_to_hdr_IPT: """ Define :func:`colour.models.hdr_ipt.XYZ_to_hdr_IPT` definition unit tests methods. @@ -230,7 +229,7 @@ def test_nan_XYZ_to_hdr_IPT(self): XYZ_to_hdr_IPT(cases, cases[..., 0], cases[..., 0]) -class TestHdr_IPT_to_XYZ(unittest.TestCase): +class TestHdr_IPT_to_XYZ: """ Define :func:`colour.models.hdr_ipt.hdr_IPT_to_XYZ` definition unit tests methods. @@ -335,7 +334,3 @@ def test_nan_hdr_IPT_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) hdr_IPT_to_XYZ(cases, cases[..., 0], cases[..., 0]) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_hunter_lab.py b/colour/models/tests/test_hunter_lab.py index e82b05b00..c79ef14b7 100644 --- a/colour/models/tests/test_hunter_lab.py +++ b/colour/models/tests/test_hunter_lab.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.hunter_lab` module.""" -import unittest from itertools import product import numpy as np @@ -29,7 +28,7 @@ ] -class TestXYZ_to_K_ab_HunterLab1966(unittest.TestCase): +class TestXYZ_to_K_ab_HunterLab1966: """ Define :func:`colour.models.hunter_lab.XYZ_to_K_ab_HunterLab1966` definition unit tests methods. @@ -98,7 +97,7 @@ def test_nan_XYZ_to_K_ab_HunterLab1966(self): XYZ_to_K_ab_HunterLab1966(cases) -class TestXYZ_to_Hunter_Lab(unittest.TestCase): +class TestXYZ_to_Hunter_Lab: """ Define :func:`colour.models.hunter_lab.XYZ_to_Hunter_Lab` definition unit tests methods. @@ -233,7 +232,7 @@ def test_nan_XYZ_to_Hunter_Lab(self): XYZ_to_Hunter_Lab(cases, cases, cases[..., 0:2]) -class TestHunter_Lab_to_XYZ(unittest.TestCase): +class TestHunter_Lab_to_XYZ: """ Define :func:`colour.models.hunter_lab.Hunter_Lab_to_XYZ` definition unit tests methods. @@ -366,7 +365,3 @@ def test_nan_Hunter_Lab_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) Hunter_Lab_to_XYZ(cases, cases, cases[..., 0:2]) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_hunter_rdab.py b/colour/models/tests/test_hunter_rdab.py index e2389bfea..f5bbb6145 100644 --- a/colour/models/tests/test_hunter_rdab.py +++ b/colour/models/tests/test_hunter_rdab.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.hunter_rdab` module.""" -import unittest from itertools import product import numpy as np @@ -24,7 +23,7 @@ ] -class TestXYZ_to_Hunter_Rdab(unittest.TestCase): +class TestXYZ_to_Hunter_Rdab: """ Define :func:`colour.models.hunter_rdab.XYZ_to_Hunter_Rdab` definition unit tests methods. @@ -159,7 +158,7 @@ def test_nan_XYZ_to_Hunter_Rdab(self): XYZ_to_Hunter_Rdab(cases, cases, cases[..., 0:2]) -class TestHunter_Rdab_to_XYZ(unittest.TestCase): +class TestHunter_Rdab_to_XYZ: """ Define :func:`colour.models.hunter_rdab.Hunter_Rdab_to_XYZ` definition unit tests methods. @@ -292,7 +291,3 @@ def test_nan_Hunter_Rdab_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) Hunter_Rdab_to_XYZ(cases, cases, cases[..., 0:2]) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_icacb.py b/colour/models/tests/test_icacb.py index 29fb89c9f..c21c20aa0 100644 --- a/colour/models/tests/test_icacb.py +++ b/colour/models/tests/test_icacb.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.hunter_rdab` module.""" -import unittest from itertools import product import numpy as np @@ -23,7 +22,7 @@ ] -class TestXYZ_to_ICaCb(unittest.TestCase): +class TestXYZ_to_ICaCb: """ Define :func:`colour.models.icacb.XYZ_to_ICaCb` definition unit tests methods. @@ -104,7 +103,7 @@ def test_nan_XYZ_to_ICaCb(self): XYZ_to_ICaCb(cases) -class TestICaCb_to_XYZ(unittest.TestCase): +class TestICaCb_to_XYZ: """Test :func:`colour.models.icacb.ICaCb_to_XYZ` definition.""" def test_XYZ_to_ICaCb(self): @@ -180,7 +179,3 @@ def test_nan_ICaCb_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) ICaCb_to_XYZ(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_igpgtg.py b/colour/models/tests/test_igpgtg.py index df131f10e..f446cd098 100644 --- a/colour/models/tests/test_igpgtg.py +++ b/colour/models/tests/test_igpgtg.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.igpgtg` module.""" -import unittest from itertools import product import numpy as np @@ -23,7 +22,7 @@ ] -class TestXYZ_to_IgPgTg(unittest.TestCase): +class TestXYZ_to_IgPgTg: """ Define :func:`colour.models.igpgtg.XYZ_to_IgPgTg` definition unit tests methods. @@ -101,7 +100,7 @@ def test_nan_XYZ_to_IgPgTg(self): XYZ_to_IgPgTg(cases) -class TestIgPgTg_to_XYZ(unittest.TestCase): +class TestIgPgTg_to_XYZ: """ Define :func:`colour.models.igpgtg.IgPgTg_to_XYZ` definition unit tests methods. @@ -177,7 +176,3 @@ def test_nan_IgPgTg_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) IgPgTg_to_XYZ(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_ipt.py b/colour/models/tests/test_ipt.py index 0c6339d68..99dd12ccb 100644 --- a/colour/models/tests/test_ipt.py +++ b/colour/models/tests/test_ipt.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.ipt` module.""" -import unittest from itertools import product import numpy as np @@ -24,7 +23,7 @@ ] -class TestXYZ_to_IPT(unittest.TestCase): +class TestXYZ_to_IPT: """Define :func:`colour.models.ipt.XYZ_to_IPT` definition unit tests methods.""" def test_XYZ_to_IPT(self): @@ -92,7 +91,7 @@ def test_nan_XYZ_to_IPT(self): XYZ_to_IPT(cases) -class TestIPT_to_XYZ(unittest.TestCase): +class TestIPT_to_XYZ: """ Define :func:`colour.models.ipt.IPT_to_XYZ` definition unit tests methods. @@ -163,7 +162,7 @@ def test_nan_IPT_to_XYZ(self): IPT_to_XYZ(cases) -class TestIPTHueAngle(unittest.TestCase): +class TestIPTHueAngle: """ Define :func:`colour.models.ipt.IPT_hue_angle` definition unit tests methods. @@ -236,7 +235,3 @@ def test_nan_IPT_hue_angle(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) IPT_hue_angle(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_jzazbz.py b/colour/models/tests/test_jzazbz.py index b67374c84..88babb6a1 100644 --- a/colour/models/tests/test_jzazbz.py +++ b/colour/models/tests/test_jzazbz.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.jzazbz` module.""" -import unittest from itertools import product import numpy as np @@ -30,7 +29,7 @@ ] -class TestXYZ_to_Izazbz(unittest.TestCase): +class TestXYZ_to_Izazbz: """ Define :func:`colour.models.jzazbz.TestXYZ_to_Izazbz` definition unit tests methods. @@ -127,7 +126,7 @@ def test_nan_XYZ_to_Izazbz(self): XYZ_to_Izazbz(cases) -class TestIzazbz_to_XYZ(unittest.TestCase): +class TestIzazbz_to_XYZ: """ Define :func:`colour.models.jzazbz.Izazbz_to_XYZ` definition unit tests methods. @@ -230,7 +229,7 @@ def test_nan_Izazbz_to_XYZ(self): Izazbz_to_XYZ(cases) -class TestXYZ_to_Jzazbz(unittest.TestCase): +class TestXYZ_to_Jzazbz: """ Define :func:`colour.models.jzazbz.TestXYZ_to_Jzazbz` definition unit tests methods. @@ -306,7 +305,7 @@ def test_nan_XYZ_to_Jzazbz(self): XYZ_to_Jzazbz(cases) -class TestJzazbz_to_XYZ(unittest.TestCase): +class TestJzazbz_to_XYZ: """ Define :func:`colour.models.jzazbz.Jzazbz_to_XYZ` definition unit tests methods. @@ -382,7 +381,3 @@ def test_nan_Jzazbz_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) Jzazbz_to_XYZ(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_oklab.py b/colour/models/tests/test_oklab.py index eef65a7d2..e465fc332 100644 --- a/colour/models/tests/test_oklab.py +++ b/colour/models/tests/test_oklab.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.oklab` module.""" -import unittest from itertools import product import numpy as np @@ -23,7 +22,7 @@ ] -class TestXYZ_to_Oklab(unittest.TestCase): +class TestXYZ_to_Oklab: """ Define :func:`colour.models.oklab.TestXYZ_to_Oklab` definition unit tests methods. @@ -101,7 +100,7 @@ def test_nan_XYZ_to_Oklab(self): XYZ_to_Oklab(cases) -class TestOklab_to_XYZ(unittest.TestCase): +class TestOklab_to_XYZ: """ Define :func:`colour.models.oklab.Oklab_to_XYZ` definition unit tests methods. @@ -176,7 +175,3 @@ def test_nan_Oklab_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) Oklab_to_XYZ(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_osa_ucs.py b/colour/models/tests/test_osa_ucs.py index e0acc2f57..3d1652f03 100644 --- a/colour/models/tests/test_osa_ucs.py +++ b/colour/models/tests/test_osa_ucs.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.osa_ucs` module.""" -import unittest from itertools import product import numpy as np @@ -23,7 +22,7 @@ ] -class TestXYZ_to_OSA_UCS(unittest.TestCase): +class TestXYZ_to_OSA_UCS: """ Define :func:`colour.models.osa_ucs.XYZ_to_OSA_UCS` definition unit tests methods. @@ -101,7 +100,7 @@ def test_nan_XYZ_to_OSA_UCS(self): XYZ_to_OSA_UCS(cases) -class TestOSA_UCS_to_XYZ(unittest.TestCase): +class TestOSA_UCS_to_XYZ: """ Define :func:`colour.models.osa_ucs.OSA_UCS_to_XYZ` definition unit tests methods. @@ -184,7 +183,3 @@ def test_nan_OSA_UCS_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) OSA_UCS_to_XYZ(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_prolab.py b/colour/models/tests/test_prolab.py index fc39c9343..7376ff604 100644 --- a/colour/models/tests/test_prolab.py +++ b/colour/models/tests/test_prolab.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.prolab` module.""" -import unittest from itertools import product import numpy as np @@ -23,7 +22,7 @@ ] -class TestXYZ_to_ProLab(unittest.TestCase): +class TestXYZ_to_ProLab: """ Define :func:`colour.models.ProLab.TestXYZ_to_ProLab` definition unit tests methods. @@ -101,7 +100,7 @@ def test_nan_XYZ_to_ProLab(self): XYZ_to_ProLab(cases) -class TestProLab_to_XYZ(unittest.TestCase): +class TestProLab_to_XYZ: """ Define :func:`colour.models.ProLab.ProLab_to_XYZ` definition unit tests methods. @@ -177,7 +176,3 @@ def test_nan_ProLab_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) ProLab_to_XYZ(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_ragoo2021.py b/colour/models/tests/test_ragoo2021.py index 946376dd2..d8b3d26f2 100644 --- a/colour/models/tests/test_ragoo2021.py +++ b/colour/models/tests/test_ragoo2021.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.ragoo2021` module.""" -import unittest from itertools import product import numpy as np @@ -23,7 +22,7 @@ ] -class TestXYZ_to_IPT_Ragoo2021(unittest.TestCase): +class TestXYZ_to_IPT_Ragoo2021: """ Define :func:`colour.models.ragoo2021.XYZ_to_IPT_Ragoo2021` definition unit tests methods. @@ -103,7 +102,7 @@ def test_nan_XYZ_to_IPT_Ragoo2021(self): XYZ_to_IPT_Ragoo2021(cases) -class TestIPT_Ragoo2021_to_XYZ(unittest.TestCase): +class TestIPT_Ragoo2021_to_XYZ: """ Define :func:`colour.models.ragoo2021.IPT_Ragoo2021_to_XYZ` definition unit tests methods. @@ -181,7 +180,3 @@ def test_nan_IPT_Ragoo2021_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) IPT_Ragoo2021_to_XYZ(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/models/tests/test_yrg.py b/colour/models/tests/test_yrg.py index 5b11eb467..c79d3b72b 100644 --- a/colour/models/tests/test_yrg.py +++ b/colour/models/tests/test_yrg.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.models.yrg` module.""" -import unittest from itertools import product import numpy as np @@ -30,7 +29,7 @@ ] -class TestLMS_to_Yrg(unittest.TestCase): +class TestLMS_to_Yrg: """ Define :func:`colour.models.yrg.TestLMS_to_Yrg` definition unit tests methods. @@ -101,7 +100,7 @@ def test_nan_LMS_to_Yrg(self): LMS_to_Yrg(cases) -class TestYrg_to_LMS(unittest.TestCase): +class TestYrg_to_LMS: """ Define :func:`colour.models.yrg.Yrg_to_LMS` definition unit tests methods. """ @@ -171,7 +170,7 @@ def test_nan_Yrg_to_LMS(self): Yrg_to_LMS(cases) -class TestXYZ_to_Yrg(unittest.TestCase): +class TestXYZ_to_Yrg: """ Define :func:`colour.models.yrg.TestXYZ_to_Yrg` definition unit tests methods. @@ -238,7 +237,7 @@ def test_nan_XYZ_to_Yrg(self): XYZ_to_Yrg(cases) -class TestYrg_to_XYZ(unittest.TestCase): +class TestYrg_to_XYZ: """ Define :func:`colour.models.yrg.Yrg_to_XYZ` definition unit tests methods. """ @@ -306,7 +305,3 @@ def test_nan_Yrg_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) Yrg_to_XYZ(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/notation/tests/test_css_color_3.py b/colour/notation/tests/test_css_color_3.py index f67e6cd43..bb9567004 100644 --- a/colour/notation/tests/test_css_color_3.py +++ b/colour/notation/tests/test_css_color_3.py @@ -3,8 +3,6 @@ from __future__ import annotations -import unittest - import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS @@ -22,7 +20,7 @@ ] -class TestKeywordToRGBCSSColor3(unittest.TestCase): +class TestKeywordToRGBCSSColor3: """ Define :func:`colour.notation.css_color_3.keyword_to_RGB_CSSColor3` definition unit tests methods. @@ -47,7 +45,3 @@ def test_keyword_to_RGB_CSSColor3(self): np.array([0.94117647, 0.97254902, 1.00000000]), atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/notation/tests/test_hexadecimal.py b/colour/notation/tests/test_hexadecimal.py index 82e8fd9f9..a7068f50d 100644 --- a/colour/notation/tests/test_hexadecimal.py +++ b/colour/notation/tests/test_hexadecimal.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.notation.hexadecimal` module.""" -import unittest from itertools import product import numpy as np @@ -26,7 +25,7 @@ ] -class TestRGB_to_HEX(unittest.TestCase): +class TestRGB_to_HEX: """ Define :func:`colour.notation.hexadecimal.RGB_to_HEX` definition unit tests methods. @@ -35,20 +34,11 @@ class TestRGB_to_HEX(unittest.TestCase): def test_RGB_to_HEX(self): """Test :func:`colour.notation.hexadecimal.RGB_to_HEX` definition.""" - self.assertEqual( - RGB_to_HEX(np.array([0.45620519, 0.03081071, 0.04091952])), - "#74070a", - ) + assert RGB_to_HEX(np.array([0.45620519, 0.03081071, 0.04091952])) == "#74070a" - self.assertEqual( - RGB_to_HEX(np.array([0.00000000, 0.00000000, 0.00000000])), - "#000000", - ) + assert RGB_to_HEX(np.array([0.00000000, 0.00000000, 0.00000000])) == "#000000" - self.assertEqual( - RGB_to_HEX(np.array([1.00000000, 1.00000000, 1.00000000])), - "#ffffff", - ) + assert RGB_to_HEX(np.array([1.00000000, 1.00000000, 1.00000000])) == "#ffffff" np.testing.assert_equal( RGB_to_HEX( @@ -74,11 +64,11 @@ def test_n_dimensional_RGB_to_HEX(self): RGB = np.tile(RGB, (6, 1)) HEX = np.tile(HEX, 6) - self.assertListEqual(RGB_to_HEX(RGB).tolist(), HEX.tolist()) + assert RGB_to_HEX(RGB).tolist() == HEX.tolist() RGB = np.reshape(RGB, (2, 3, 3)) HEX = np.reshape(HEX, (2, 3)) - self.assertListEqual(RGB_to_HEX(RGB).tolist(), HEX.tolist()) + assert RGB_to_HEX(RGB).tolist() == HEX.tolist() def test_domain_range_scale_RGB_to_HEX(self): """ @@ -92,7 +82,7 @@ def test_domain_range_scale_RGB_to_HEX(self): d_r = (("reference", 1), ("1", 1), ("100", 100)) for scale, factor in d_r: with domain_range_scale(scale): - self.assertEqual(RGB_to_HEX(RGB * factor), HEX) + assert RGB_to_HEX(RGB * factor) == HEX @ignore_numpy_errors def test_nan_RGB_to_HEX(self): @@ -106,7 +96,7 @@ def test_nan_RGB_to_HEX(self): RGB_to_HEX(cases) -class TestHEX_to_RGB(unittest.TestCase): +class TestHEX_to_RGB: """ Define :func:`colour.notation.hexadecimal.HEX_to_RGB` definition unit tests methods. @@ -163,7 +153,3 @@ def test_domain_range_scale_HEX_to_RGB(self): for scale, factor in d_r: with domain_range_scale(scale): np.testing.assert_array_equal(HEX_to_RGB(HEX), RGB * factor) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/notation/tests/test_munsell.py b/colour/notation/tests/test_munsell.py index 2fcebbfdd..2099f242a 100644 --- a/colour/notation/tests/test_munsell.py +++ b/colour/notation/tests/test_munsell.py @@ -4,10 +4,10 @@ from __future__ import annotations import contextlib -import unittest from itertools import product import numpy as np +import pytest from colour.constants import TOLERANCE_ABSOLUTE_TESTS from colour.hints import NDArrayFloat @@ -1101,7 +1101,7 @@ def _generate_unit_tests_specifications() -> tuple: # pragma: no cover ] -class TestMunsellValuePriest1920(unittest.TestCase): +class TestMunsellValuePriest1920: """ Define :func:`colour.notation.munsell.munsell_value_Priest1920` definition unit tests methods. @@ -1186,7 +1186,7 @@ def test_nan_munsell_value_Priest1920(self): munsell_value_Priest1920(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestMunsellValueMunsell1933(unittest.TestCase): +class TestMunsellValueMunsell1933: """ Define :func:`colour.notation.munsell.munsell_value_Munsell1933` definition unit tests methods. @@ -1271,7 +1271,7 @@ def test_nan_munsell_value_Munsell1933(self): munsell_value_Munsell1933(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestMunsellValueMoon1943(unittest.TestCase): +class TestMunsellValueMoon1943: """ Define :func:`colour.notation.munsell.munsell_value_Moon1943` definition unit tests methods. @@ -1356,7 +1356,7 @@ def test_nan_munsell_value_Moon1943(self): munsell_value_Moon1943(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestMunsellValueSaunderson1944(unittest.TestCase): +class TestMunsellValueSaunderson1944: """ Define :func:`colour.notation.munsell.munsell_value_Saunderson1944` definition unit tests methods. @@ -1443,7 +1443,7 @@ def test_nan_munsell_value_Saunderson1944(self): ) -class TestMunsellValueLadd1955(unittest.TestCase): +class TestMunsellValueLadd1955: """ Define :func:`colour.notation.munsell.munsell_value_Ladd1955` definition unit tests methods. @@ -1528,7 +1528,7 @@ def test_nan_munsell_value_Ladd1955(self): munsell_value_Ladd1955(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestMunsellValueMcCamy1992(unittest.TestCase): +class TestMunsellValueMcCamy1992: """ Define :func:`colour.notation.munsell.munsell_value_McCamy1987` definition unit tests methods. @@ -1613,7 +1613,7 @@ def test_nan_munsell_value_McCamy1987(self): munsell_value_McCamy1987(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestMunsellValueASTMD1535(unittest.TestCase): +class TestMunsellValueASTMD1535: """ Define :func:`colour.notation.munsell.munsell_value_ASTMD1535` definition unit tests methods. @@ -1698,7 +1698,7 @@ def test_nan_munsell_value_ASTMD1535(self): munsell_value_ASTMD1535(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestMunsellSpecification_to_xyY(unittest.TestCase): +class TestMunsellSpecification_to_xyY: """ Define :func:`colour.notation.munsell.munsell_specification_to_xyY` definition unit tests methods. @@ -1814,7 +1814,7 @@ def test_nan_munsell_specification_to_xyY(self): munsell_specification_to_xyY(case) -class TestMunsellColour_to_xyY(unittest.TestCase): +class TestMunsellColour_to_xyY: """ Define :func:`colour.notation.munsell.munsell_colour_to_xyY` definition unit tests methods. @@ -1887,7 +1887,7 @@ def test_n_dimensional_munsell_colour_to_xyY(self): ) -class TestxyY_to_munsell_specification(unittest.TestCase): +class TestxyY_to_munsell_specification: """ Define :func:`colour.notation.munsell.xyY_to_munsell_specification` definition unit tests methods. @@ -1955,7 +1955,7 @@ def test_raise_exception_xyY_to_munsell_specification(self): definition raised exception. """ - self.assertRaises( + pytest.raises( RuntimeError, xyY_to_munsell_specification, np.array([0.90615118, 0.57945103, 0.91984064]), @@ -1997,7 +1997,7 @@ def test_nan_xyY_to_munsell_specification(self): xyY_to_munsell_specification(case) -class TestxyY_to_munsell_colour(unittest.TestCase): +class TestxyY_to_munsell_colour: """ Define :func:`colour.notation.munsell.xyY_to_munsell_colour` definition unit tests methods. @@ -2019,7 +2019,7 @@ def test_domain_range_scale_xyY_to_munsell_colour(self): ) for scale, factor in d_r: with domain_range_scale(scale): - self.assertEqual(xyY_to_munsell_colour(xyY * factor), munsell_colour) + assert xyY_to_munsell_colour(xyY * factor) == munsell_colour def test_n_dimensional_xyY_to_munsell_colour(self): """ @@ -2050,7 +2050,7 @@ def test_n_dimensional_xyY_to_munsell_colour(self): np.testing.assert_equal(xyY_to_munsell_colour(xyY), munsell_colour) -class TestParseMunsellColour(unittest.TestCase): +class TestParseMunsellColour: """ Define :func:`colour.notation.munsell.parse_munsell_colour` definition unit tests methods. @@ -2086,10 +2086,10 @@ def test_raise_exception_parse_munsell_colour(self): definition raised exception. """ - self.assertRaises(ValueError, parse_munsell_colour, "4.2YQ 8.1/5.3") + pytest.raises(ValueError, parse_munsell_colour, "4.2YQ 8.1/5.3") -class TestIsGreyMunsellColour(unittest.TestCase): +class TestIsGreyMunsellColour: """ Define :func:`colour.notation.munsell.is_grey_munsell_colour` definition unit tests methods. @@ -2101,16 +2101,16 @@ def test_is_grey_munsell_colour(self): definition. """ - self.assertTrue(is_grey_munsell_colour(5.2)) + assert is_grey_munsell_colour(5.2) - self.assertFalse(is_grey_munsell_colour(np.array([0.0, 2.0, 4.0, 6]))) + assert not is_grey_munsell_colour(np.array([0.0, 2.0, 4.0, 6])) - self.assertFalse(is_grey_munsell_colour(np.array([4.2, 8.1, 5.3, 6]))) + assert not is_grey_munsell_colour(np.array([4.2, 8.1, 5.3, 6])) - self.assertTrue(is_grey_munsell_colour(np.array([np.nan, 0.5, np.nan, np.nan]))) + assert is_grey_munsell_colour(np.array([np.nan, 0.5, np.nan, np.nan])) -class TestNormaliseMunsellSpecification(unittest.TestCase): +class TestNormaliseMunsellSpecification: """ Define :func:`colour.notation.munsell.normalise_munsell_specification` definition unit tests methods. @@ -2147,7 +2147,7 @@ def test_normalise_munsell_specification(self): ) -class TestMunsellColourToMunsellSpecification(unittest.TestCase): +class TestMunsellColourToMunsellSpecification: """ Define :func:`colour.notation.munsell.\ munsell_colour_to_munsell_specification` definition unit tests methods. @@ -2190,7 +2190,7 @@ def test_munsell_colour_to_munsell_specification(self): ) -class TestMunsellSpecificationToMunsellColour(unittest.TestCase): +class TestMunsellSpecificationToMunsellColour: """ Define :func:`colour.notation.munsell.\ munsell_specification_to_munsell_colour` definition unit tests methods. @@ -2202,40 +2202,40 @@ def test_munsell_specification_to_munsell_colour(self): munsell_specification_to_munsell_colour` definition. """ - self.assertEqual( - munsell_specification_to_munsell_colour(np.array([10.0, 2.0, 4.0, 7])), - "10.0R 2.0/4.0", + assert ( + munsell_specification_to_munsell_colour(np.array([10.0, 2.0, 4.0, 7])) + == "10.0R 2.0/4.0" ) - self.assertEqual( - munsell_specification_to_munsell_colour(np.array([10.0, 2.0, 4.0, 9])), - "10.0P 2.0/4.0", + assert ( + munsell_specification_to_munsell_colour(np.array([10.0, 2.0, 4.0, 9])) + == "10.0P 2.0/4.0" ) - self.assertEqual( - munsell_specification_to_munsell_colour(np.array([10.0, 2.0, 4.0, 1])), - "10.0B 2.0/4.0", + assert ( + munsell_specification_to_munsell_colour(np.array([10.0, 2.0, 4.0, 1])) + == "10.0B 2.0/4.0" ) - self.assertEqual( + assert ( munsell_specification_to_munsell_colour( np.array([np.nan, 5.2, np.nan, np.nan]) - ), - "N5.2", + ) + == "N5.2" ) - self.assertEqual( - munsell_specification_to_munsell_colour(np.array([0.0, 2.0, 4.0, 7])), - "10.0RP 2.0/4.0", + assert ( + munsell_specification_to_munsell_colour(np.array([0.0, 2.0, 4.0, 7])) + == "10.0RP 2.0/4.0" ) - self.assertEqual( - munsell_specification_to_munsell_colour(np.array([10.0, 0.0, 4.0, 7])), - "N0.0", + assert ( + munsell_specification_to_munsell_colour(np.array([10.0, 0.0, 4.0, 7])) + == "N0.0" ) -class Test_xyY_fromRenotation(unittest.TestCase): +class Test_xyY_fromRenotation: """ Define :func:`colour.notation.munsell.xyY_from_renotation` definition unit tests methods. @@ -2263,7 +2263,7 @@ def test_xyY_from_renotation(self): ) -class TestIsSpecificationInRenotation(unittest.TestCase): +class TestIsSpecificationInRenotation: """ Define :func:`colour.notation.munsell.is_specification_in_renotation` definition unit tests methods. @@ -2275,14 +2275,14 @@ def test_is_specification_in_renotation(self): definition. """ - self.assertTrue(is_specification_in_renotation(np.array([2.5, 0.2, 2.0, 4]))) + assert is_specification_in_renotation(np.array([2.5, 0.2, 2.0, 4])) - self.assertTrue(is_specification_in_renotation(np.array([5.0, 0.2, 2.0, 4]))) + assert is_specification_in_renotation(np.array([5.0, 0.2, 2.0, 4])) - self.assertFalse(is_specification_in_renotation(np.array([25.0, 0.2, 2.0, 4]))) + assert not is_specification_in_renotation(np.array([25.0, 0.2, 2.0, 4])) -class TestBoundingHuesFromRenotation(unittest.TestCase): +class TestBoundingHuesFromRenotation: """ Define :func:`colour.notation.munsell.bounding_hues_from_renotation` definition unit tests methods. @@ -2302,7 +2302,7 @@ def test_bounding_hues_from_renotation(self): ) -class TestHueToHueAngle(unittest.TestCase): +class TestHueToHueAngle: """ Define :func:`colour.notation.munsell.hue_to_hue_angle` definition unit tests methods. @@ -2312,10 +2312,10 @@ def test_hue_to_hue_angle(self): """Test :func:`colour.notation.munsell.hue_to_hue_angle` definition.""" for hue, code, angle in MUNSELL_HUE_TO_ANGLE: - self.assertEqual(hue_to_hue_angle([hue, code]), angle) + assert hue_to_hue_angle([hue, code]) == angle -class TestHueAngleToHue(unittest.TestCase): +class TestHueAngleToHue: """ Define :func:`colour.notation.munsell.hue_angle_to_hue` definition unit tests methods. @@ -2328,7 +2328,7 @@ def test_hue_angle_to_hue(self): np.testing.assert_array_equal(hue_angle_to_hue(angle), (hue, code)) -class TestHueTo_ASTM_hue(unittest.TestCase): +class TestHueTo_ASTM_hue: """ Define :func:`colour.notation.munsell.hue_to_ASTM_hue` definition unit tests methods. @@ -2338,10 +2338,10 @@ def test_hue_to_ASTM_hue(self): """Test :func:`colour.notation.munsell.hue_to_ASTM_hue` definition.""" for hue, code, angle in MUNSELL_HUE_TO_ASTM_HUE: - self.assertEqual(hue_to_ASTM_hue([hue, code]), angle) + assert hue_to_ASTM_hue([hue, code]) == angle -class TestInterpolationMethodFromRenotationOvoid(unittest.TestCase): +class TestInterpolationMethodFromRenotationOvoid: """ Define :func:`colour.notation.munsell.\ interpolation_method_from_renotation_ovoid` definition unit tests methods. @@ -2354,23 +2354,25 @@ def test_interpolation_method_from_renotation_ovoid(self): """ for i, (specification, _xyY) in enumerate(MUNSELL_EVEN_SPECIFICATIONS): - self.assertEqual( - interpolation_method_from_renotation_ovoid(specification), - MUNSELL_INTERPOLATION_METHODS[i], + assert ( + interpolation_method_from_renotation_ovoid(specification) + == MUNSELL_INTERPOLATION_METHODS[i] ) - self.assertIsNone( + assert ( interpolation_method_from_renotation_ovoid( np.array([np.nan, 5.2, np.nan, np.nan]) ) + is None ) - self.assertIsNone( + assert ( interpolation_method_from_renotation_ovoid(np.array([2.5, 10.0, 2.0, 4])) + is None ) -class Test_xy_fromRenotationOvoid(unittest.TestCase): +class Test_xy_fromRenotationOvoid: """ Define :func:`colour.notation.munsell.xy_from_renotation_ovoid` definition unit tests methods. @@ -2391,7 +2393,7 @@ def test_xy_from_renotation_ovoid(self): ) -class TestLCHabToMunsellSpecification(unittest.TestCase): +class TestLCHabToMunsellSpecification: """ Define :func:`colour.notation.munsell.LCHab_to_munsell_specification` definition unit tests methods. @@ -2444,7 +2446,7 @@ def test_LCHab_to_munsell_specification(self): ) -class TestMaximumChromaFromRenotation(unittest.TestCase): +class TestMaximumChromaFromRenotation: """ Define :func:`colour.notation.munsell.maximum_chroma_from_renotation` definition unit tests methods. @@ -2456,14 +2458,14 @@ def test_maximum_chroma_from_renotation(self): definition. """ - self.assertEqual(maximum_chroma_from_renotation([2.5, 5, 5]), 14.0) + assert maximum_chroma_from_renotation([2.5, 5, 5]) == 14.0 - self.assertEqual(maximum_chroma_from_renotation([8.675, 1.225, 10]), 48.0) + assert maximum_chroma_from_renotation([8.675, 1.225, 10]) == 48.0 - self.assertEqual(maximum_chroma_from_renotation([6.875, 3.425, 1]), 16.0) + assert maximum_chroma_from_renotation([6.875, 3.425, 1]) == 16.0 -class TestMunsellSpecification_to_xy(unittest.TestCase): +class TestMunsellSpecification_to_xy: """ Define :func:`colour.notation.munsell.munsell_specification_to_xy` definition unit tests methods. @@ -2488,7 +2490,3 @@ def test_munsell_specification_to_xy(self): xyY[0:2], atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/phenomena/tests/test_rayleigh.py b/colour/phenomena/tests/test_rayleigh.py index b1fcef92a..5c2309a1f 100644 --- a/colour/phenomena/tests/test_rayleigh.py +++ b/colour/phenomena/tests/test_rayleigh.py @@ -3,8 +3,6 @@ from __future__ import annotations -import unittest - import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS @@ -482,7 +480,7 @@ ) -class TestAirRefractionIndexPenndorf1957(unittest.TestCase): +class TestAirRefractionIndexPenndorf1957: """ Define :func:`colour.phenomena.rayleigh.\ air_refraction_index_Penndorf1957` definition unit tests methods. @@ -557,7 +555,7 @@ def test_nan_air_refraction_index_Penndorf1957(self): ) -class TestAirRefractionIndexEdlen1966(unittest.TestCase): +class TestAirRefractionIndexEdlen1966: """ Define :func:`colour.phenomena.rayleigh.air_refraction_index_Edlen1966` definition unit tests methods. @@ -632,7 +630,7 @@ def test_nan_air_refraction_index_Edlen1966(self): ) -class TestAirRefractionIndexPeck1972(unittest.TestCase): +class TestAirRefractionIndexPeck1972: """ Define :func:`colour.phenomena.rayleigh.air_refraction_index_Peck1972` definition unit tests methods. @@ -701,7 +699,7 @@ def test_nan_air_refraction_index_Peck1972(self): ) -class TestAirRefractionIndexBodhaine1999(unittest.TestCase): +class TestAirRefractionIndexBodhaine1999: """ Define :func:`colour.phenomena.rayleigh.\ air_refraction_index_Bodhaine1999` definition unit tests methods. @@ -793,7 +791,7 @@ def test_nan_air_refraction_index_Bodhaine1999(self): air_refraction_index_Bodhaine1999(cases, cases) -class TestN2Depolarisation(unittest.TestCase): +class TestN2Depolarisation: """ Define :func:`colour.phenomena.rayleigh.N2_depolarisation` definition unit tests methods. @@ -857,7 +855,7 @@ def test_nan_N2_depolarisation(self): N2_depolarisation(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestO2Depolarisation(unittest.TestCase): +class TestO2Depolarisation: """ Define :func:`colour.phenomena.rayleigh.O2_depolarisation` definition unit tests methods. @@ -921,7 +919,7 @@ def test_nan_O2_depolarisation(self): O2_depolarisation(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestF_airPenndorf1957(unittest.TestCase): +class TestF_airPenndorf1957: """ Define :func:`colour.phenomena.rayleigh.F_air_Penndorf1957` definition unit tests methods. @@ -933,7 +931,7 @@ def test_F_air_Penndorf1957(self): definition. """ - self.assertEqual(F_air_Penndorf1957(0.360), 1.0608) + assert F_air_Penndorf1957(0.360) == 1.0608 def test_n_dimensional_F_air_Penndorf1957(self): """ @@ -972,7 +970,7 @@ def test_nan_F_air_Penndorf1957(self): F_air_Penndorf1957(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestF_airYoung1981(unittest.TestCase): +class TestF_airYoung1981: """ Define :func:`colour.phenomena.rayleigh.F_air_Young1981` definition unit tests methods. @@ -981,7 +979,7 @@ class TestF_airYoung1981(unittest.TestCase): def test_F_air_Young1981(self): """Test :func:`colour.phenomena.rayleigh.F_air_Young1981` definition.""" - self.assertEqual(F_air_Young1981(0.360), 1.0480) + assert F_air_Young1981(0.360) == 1.0480 def test_n_dimensional_F_air_Young1981(self): """ @@ -1020,7 +1018,7 @@ def test_nan_F_air_Young1981(self): F_air_Young1981(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestF_airBates1984(unittest.TestCase): +class TestF_airBates1984: """ Define :func:`colour.phenomena.rayleigh.F_air_Bates1984` definition unit tests methods. @@ -1084,7 +1082,7 @@ def test_nan_F_air_Bates1984(self): F_air_Bates1984(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestF_airBodhaine1999(unittest.TestCase): +class TestF_airBodhaine1999: """ Define :func:`colour.phenomena.rayleigh.F_air_Bodhaine1999` definition unit tests methods. @@ -1170,7 +1168,7 @@ def test_nan_F_air_Bodhaine1999(self): F_air_Bodhaine1999(cases, cases) -class TestMolecularDensity(unittest.TestCase): +class TestMolecularDensity: """ Define :func:`colour.phenomena.rayleigh.molecular_density` definition unit tests methods. @@ -1228,7 +1226,7 @@ def test_nan_molecular_density(self): molecular_density(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestMeanMolecularWeights(unittest.TestCase): +class TestMeanMolecularWeights: """ Define :func:`colour.phenomena.rayleigh.mean_molecular_weights` definition unit tests methods. @@ -1293,7 +1291,7 @@ def test_nan_mean_molecular_weights(self): mean_molecular_weights(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])) -class TestGravityList1968(unittest.TestCase): +class TestGravityList1968: """ Define :func:`colour.phenomena.rayleigh.gravity_List1968` definition unit tests methods. @@ -1349,7 +1347,7 @@ def test_nan_gravity_List1968(self): gravity_List1968(cases, cases) -class TestScatteringCrossSection(unittest.TestCase): +class TestScatteringCrossSection: """ Define :func:`colour.phenomena.rayleigh.scattering_cross_section` definition unit tests methods. @@ -1450,7 +1448,7 @@ def test_nan_scattering_cross_section(self): scattering_cross_section(cases, cases, cases) -class TestRayleighOpticalDepth(unittest.TestCase): +class TestRayleighOpticalDepth: """ Define :func:`colour.phenomena.rayleigh.rayleigh_optical_depth` definition unit tests methods. @@ -1587,7 +1585,7 @@ def test_nan_rayleigh_optical_depth(self): rayleigh_optical_depth(cases, cases, cases, cases, cases) -class TestSdRayleighScattering(unittest.TestCase): +class TestSdRayleighScattering: """ Define :func:`colour.phenomena.rayleigh.sd_rayleigh_scattering` definition unit tests methods. @@ -1604,7 +1602,3 @@ def test_sd_rayleigh_scattering(self): DATA_SD_RAYLEIGH_SCATTERING, atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/plotting/tests/test_blindness.py b/colour/plotting/tests/test_blindness.py index 70ec3b3fb..a178c72e8 100644 --- a/colour/plotting/tests/test_blindness.py +++ b/colour/plotting/tests/test_blindness.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.plotting.blindness` module.""" -import unittest import numpy as np from matplotlib.axes import Axes @@ -21,7 +20,7 @@ ] -class TestPlotCvdSimulationMachado2009(unittest.TestCase): +class TestPlotCvdSimulationMachado2009: """ Define :func:`colour.plotting.blindness.plot_cvd_simulation_Machado2009` definition unit tests methods. @@ -35,9 +34,5 @@ def test_plot_cvd_simulation_Machado2009(self): figure, axes = plot_cvd_simulation_Machado2009(np.random.rand(32, 32, 3)) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) - - -if __name__ == "__main__": - unittest.main() + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) diff --git a/colour/plotting/tests/test_characterisation.py b/colour/plotting/tests/test_characterisation.py index 87d606449..5446e598a 100644 --- a/colour/plotting/tests/test_characterisation.py +++ b/colour/plotting/tests/test_characterisation.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.plotting.characterisation` module.""" -import unittest from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -24,7 +23,7 @@ ] -class TestPlotSingleColourChecker(unittest.TestCase): +class TestPlotSingleColourChecker: """ Define :func:`colour.plotting.characterisation.plot_single_colour_checker` definition unit tests methods. @@ -38,11 +37,11 @@ def test_plot_single_colour_checker(self): figure, axes = plot_single_colour_checker() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotMultiColourCheckers(unittest.TestCase): +class TestPlotMultiColourCheckers: """ Define :func:`colour.plotting.characterisation.plot_multi_colour_checkers` definition unit tests methods. @@ -58,9 +57,5 @@ def test_plot_multi_colour_checkers(self): ["ColorChecker 1976", "ColorChecker 2005"] ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) - - -if __name__ == "__main__": - unittest.main() + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) diff --git a/colour/plotting/tests/test_colorimetry.py b/colour/plotting/tests/test_colorimetry.py index 25e433424..f0b1f0942 100644 --- a/colour/plotting/tests/test_colorimetry.py +++ b/colour/plotting/tests/test_colorimetry.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.plotting.colorimetry` module.""" -import unittest from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -47,7 +46,7 @@ ] -class TestPlotSingleSd(unittest.TestCase): +class TestPlotSingleSd: """ Define :func:`colour.plotting.colorimetry.plot_single_sd` definition unit tests methods. @@ -76,11 +75,11 @@ def test_plot_single_sd(self): equalize_sd_amplitude=True, ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotMultiSds(unittest.TestCase): +class TestPlotMultiSds: """ Define :func:`colour.plotting.colorimetry.plot_multi_sds` definition unit tests methods. @@ -119,19 +118,19 @@ def test_plot_multi_sds(self): plot_kwargs={"use_sd_colours": True, "normalise_sd_colours": True}, ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_multi_sds( [sd_1, sd_2], plot_kwargs=[{"use_sd_colours": True, "normalise_sd_colours": True}] * 2, ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotSingleCmfs(unittest.TestCase): +class TestPlotSingleCmfs: """ Define :func:`colour.plotting.colorimetry.plot_single_cmfs` definition unit tests methods. @@ -142,11 +141,11 @@ def test_plot_single_cmfs(self): figure, axes = plot_single_cmfs() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotMultiCmfs(unittest.TestCase): +class TestPlotMultiCmfs: """ Define :func:`colour.plotting.colorimetry.plot_multi_cmfs` definition unit tests methods. @@ -162,11 +161,11 @@ def test_plot_multi_cmfs(self): ] ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotSingleIlluminantSd(unittest.TestCase): +class TestPlotSingleIlluminantSd: """ Define :func:`colour.plotting.colorimetry.plot_single_illuminant_sd` definition unit tests methods. @@ -180,11 +179,11 @@ def test_plot_single_illuminant_sd(self): figure, axes = plot_single_illuminant_sd("A") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotMultiIlluminantSds(unittest.TestCase): +class TestPlotMultiIlluminantSds: """ Define :func:`colour.plotting.colorimetry.plot_multi_illuminant_sds` definition unit tests methods. @@ -198,19 +197,19 @@ def test_plot_multi_illuminant_sds(self): figure, axes = plot_multi_illuminant_sds(["A", "B", "C"]) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_multi_illuminant_sds( ["A", "B", "C"], plot_kwargs=[{"use_sd_colours": True, "normalise_sd_colours": True}] * 3, ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotVisibleSpectrum(unittest.TestCase): +class TestPlotVisibleSpectrum: """ Define :func:`colour.plotting.colorimetry.plot_visible_spectrum` definition unit tests methods. @@ -224,11 +223,11 @@ def test_plot_visible_spectrum(self): figure, axes = plot_visible_spectrum() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotSingleLightnessFunction(unittest.TestCase): +class TestPlotSingleLightnessFunction: """ Define :func:`colour.plotting.colorimetry.plot_single_lightness_function` definition unit tests methods. @@ -242,11 +241,11 @@ def test_plot_single_lightness_function(self): figure, axes = plot_single_lightness_function("CIE 1976") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotMultiLightnessFunctions(unittest.TestCase): +class TestPlotMultiLightnessFunctions: """ Define :func:`colour.plotting.colorimetry.plot_multi_lightness_functions` definition unit tests methods. @@ -260,11 +259,11 @@ def test_plot_multi_lightness_functions(self): figure, axes = plot_multi_lightness_functions(["CIE 1976", "Wyszecki 1963"]) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotSingleLuminanceFunction(unittest.TestCase): +class TestPlotSingleLuminanceFunction: """ Define :func:`colour.plotting.colorimetry.plot_single_luminance_function` definition unit tests methods. @@ -278,11 +277,11 @@ def test_plot_single_luminance_function(self): figure, axes = plot_single_luminance_function("CIE 1976") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotMultiLuminanceFunctions(unittest.TestCase): +class TestPlotMultiLuminanceFunctions: """ Define :func:`colour.plotting.colorimetry.plot_multi_luminance_functions` definition unit tests methods. @@ -296,11 +295,11 @@ def test_plot_multi_luminance_functions(self): figure, axes = plot_multi_luminance_functions(["CIE 1976", "Newhall 1943"]) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotBlackbodySpectralRadiance(unittest.TestCase): +class TestPlotBlackbodySpectralRadiance: """ Define :func:`colour.plotting.colorimetry.\ plot_blackbody_spectral_radiance` definition unit tests methods. @@ -314,11 +313,11 @@ def test_plot_blackbody_spectral_radiance(self): figure, axes = plot_blackbody_spectral_radiance() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotBlackbodyColours(unittest.TestCase): +class TestPlotBlackbodyColours: """ Define :func:`colour.plotting.colorimetry.plot_blackbody_colours` definition unit tests methods. @@ -332,9 +331,5 @@ def test_plot_blackbody_colours(self): figure, axes = plot_blackbody_colours() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) - - -if __name__ == "__main__": - unittest.main() + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) diff --git a/colour/plotting/tests/test_common.py b/colour/plotting/tests/test_common.py index 28199fc6a..17104a079 100644 --- a/colour/plotting/tests/test_common.py +++ b/colour/plotting/tests/test_common.py @@ -4,7 +4,6 @@ import os import shutil import tempfile -import unittest from functools import partial import matplotlib.font_manager @@ -76,7 +75,7 @@ ] -class TestColourStyle(unittest.TestCase): +class TestColourStyle: """ Define :func:`colour.plotting.common.colour_style` definition unit tests methods. @@ -85,10 +84,10 @@ class TestColourStyle(unittest.TestCase): def test_colour_style(self): """Test :func:`colour.plotting.common.colour_style` definition.""" - self.assertIsInstance(colour_style(use_style=False), dict) + assert isinstance(colour_style(use_style=False), dict) -class TestOverrideStyle(unittest.TestCase): +class TestOverrideStyle: """ Define :func:`colour.plotting.common.override_style` definition unit tests methods. @@ -111,7 +110,7 @@ def test_text_color_override(): plt.rcParams["text.color"] = text_color -class TestFontScaling(unittest.TestCase): +class TestFontScaling: """ Define :func:`colour.plotting.common.font_scaling` definition unit tests methods. @@ -121,17 +120,12 @@ def test_font_scaling(self): """Test :func:`colour.plotting.common.font_scaling` definition.""" with font_scaling("medium-colour-science", 2): - self.assertEqual( - matplotlib.font_manager.font_scalings["medium-colour-science"], - 2, - ) + assert matplotlib.font_manager.font_scalings["medium-colour-science"] == 2 - self.assertEqual( - matplotlib.font_manager.font_scalings["medium-colour-science"], 1 - ) + assert matplotlib.font_manager.font_scalings["medium-colour-science"] == 1 -class TestXYZToPlottingColourspace(unittest.TestCase): +class TestXYZToPlottingColourspace: """ Define :func:`colour.plotting.common.XYZ_to_plotting_colourspace` definition unit tests methods. @@ -151,7 +145,7 @@ def test_XYZ_to_plotting_colourspace(self): ) -class TestColourCycle(unittest.TestCase): +class TestColourCycle: """ Define :func:`colour.plotting.common.colour_cycle` definition unit tests methods. @@ -189,7 +183,7 @@ def test_colour_cycle(self): ) -class TestArtist(unittest.TestCase): +class TestArtist: """ Define :func:`colour.plotting.common.artist` definition unit tests methods. @@ -206,29 +200,29 @@ def test_axes_args(self): fig_result1, _ = artist(axes=ax1) - self.assertIs(fig1, fig_result1) + assert fig1 is fig_result1 _ = plt.figure() fig_result2, _ = artist(axes=ax1) - self.assertIs(fig1, fig_result2) + assert fig1 is fig_result2 def test_artist(self): """Test :func:`colour.plotting.common.artist` definition.""" figure_1, axes_1 = artist() - self.assertIsInstance(figure_1, Figure) - self.assertIsInstance(axes_1, Axes) + assert isinstance(figure_1, Figure) + assert isinstance(axes_1, Axes) _figure_2, axes_2 = artist(axes=axes_1, uniform=True) - self.assertIs(axes_1, axes_2) + assert axes_1 is axes_2 figure_3, _axes_3 = artist(uniform=True) - self.assertEqual(figure_3.get_figwidth(), figure_3.get_figheight()) + assert figure_3.get_figwidth() == figure_3.get_figheight() -class TestCamera(unittest.TestCase): +class TestCamera: """ Define :func:`colour.plotting.common.camera` definition unit tests methods. @@ -242,22 +236,22 @@ def test_camera(self): _figure, axes = camera(axes=axes, elevation=45, azimuth=90) - self.assertEqual(axes.elev, 45) - self.assertEqual(axes.azim, 90) + assert axes.elev == 45 + assert axes.azim == 90 -class TestRender(unittest.TestCase): +class TestRender: """ Define :func:`colour.plotting.common.render` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def tearDown(self): + def teardown_method(self): """After tests actions.""" shutil.rmtree(self._temporary_directory) @@ -294,7 +288,7 @@ def test_render(self): ) -class TestLabelRectangles(unittest.TestCase): +class TestLabelRectangles: """ Define :func:`colour.plotting.common.label_rectangles` definition unit tests methods. @@ -311,10 +305,10 @@ def test_label_rectangles(self): samples, axes.bar(samples, 1), figure=figure, axes=axes ) - self.assertEqual(len(axes.texts), len(samples)) + assert len(axes.texts) == len(samples) -class TestUniformAxes3d(unittest.TestCase): +class TestUniformAxes3d: """ Define :func:`colour.plotting.common.uniform_axes3d` definition unit tests methods. @@ -328,11 +322,11 @@ def test_uniform_axes3d(self): uniform_axes3d(axes=axes) - self.assertEqual(axes.get_xlim(), axes.get_ylim()) - self.assertEqual(axes.get_xlim(), axes.get_zlim()) + assert axes.get_xlim() == axes.get_ylim() + assert axes.get_xlim() == axes.get_zlim() -class TestFilterPassthrough(unittest.TestCase): +class TestFilterPassthrough: """ Define :func:`colour.plotting.common.filter_passthrough` definition unit tests methods. @@ -341,56 +335,42 @@ class TestFilterPassthrough(unittest.TestCase): def test_filter_passthrough(self): """Test :func:`colour.plotting.common.filter_passthrough` definition.""" - self.assertListEqual( - sorted( - colourspace.name - for colourspace in filter_passthrough( - RGB_COLOURSPACES, ["ACES2065-1"] - ).values() - ), - ["ACES2065-1"], - ) + assert sorted( + colourspace.name + for colourspace in filter_passthrough( + RGB_COLOURSPACES, ["ACES2065-1"] + ).values() + ) == ["ACES2065-1"] - self.assertListEqual( - sorted(filter_passthrough(RGB_COLOURSPACES, ["aces2065-1"]).keys()), - ["ACES2065-1"], - ) + assert sorted(filter_passthrough(RGB_COLOURSPACES, ["aces2065-1"]).keys()) == [ + "ACES2065-1" + ] - self.assertListEqual( - sorted(filter_passthrough(RGB_COLOURSPACES, ["aces20651"]).keys()), - ["ACES2065-1"], - ) + assert sorted(filter_passthrough(RGB_COLOURSPACES, ["aces20651"]).keys()) == [ + "ACES2065-1" + ] - self.assertDictEqual( - filter_passthrough( - SDS_ILLUMINANTS, - [SDS_ILLUMINANTS["D65"], {"Is": "Excluded"}], - allow_non_siblings=False, - ), - {"D65": SDS_ILLUMINANTS["D65"]}, - ) + assert filter_passthrough( + SDS_ILLUMINANTS, + [SDS_ILLUMINANTS["D65"], {"Is": "Excluded"}], + allow_non_siblings=False, + ) == {"D65": SDS_ILLUMINANTS["D65"]} - self.assertDictEqual( - filter_passthrough( - SDS_ILLUMINANTS, - [SDS_ILLUMINANTS["D65"], {"Is": "Included"}], - allow_non_siblings=True, - ), - {"D65": SDS_ILLUMINANTS["D65"], "Is": "Included"}, - ) + assert filter_passthrough( + SDS_ILLUMINANTS, + [SDS_ILLUMINANTS["D65"], {"Is": "Included"}], + allow_non_siblings=True, + ) == {"D65": SDS_ILLUMINANTS["D65"], "Is": "Included"} - self.assertListEqual( - sorted( - element - for element in filter_passthrough( - {"John": "Doe", "Luke": "Skywalker"}, ["John"] - ).values() - ), - ["Doe", "John"], - ) + assert sorted( + element + for element in filter_passthrough( + {"John": "Doe", "Luke": "Skywalker"}, ["John"] + ).values() + ) == ["Doe", "John"] -class TestFilterRgbColourspaces(unittest.TestCase): +class TestFilterRgbColourspaces: """ Define :func:`colour.plotting.common.filter_RGB_colourspaces` definition unit tests methods. @@ -402,16 +382,13 @@ def test_filter_RGB_colourspaces(self): definition. """ - self.assertListEqual( - sorted( - colourspace.name - for colourspace in filter_RGB_colourspaces(["ACES2065-1"]).values() - ), - ["ACES2065-1"], - ) + assert sorted( + colourspace.name + for colourspace in filter_RGB_colourspaces(["ACES2065-1"]).values() + ) == ["ACES2065-1"] -class TestFilterCmfs(unittest.TestCase): +class TestFilterCmfs: """ Define :func:`colour.plotting.common.filter_cmfs` definition unit tests methods. @@ -420,20 +397,15 @@ class TestFilterCmfs(unittest.TestCase): def test_filter_cmfs(self): """Test :func:`colour.plotting.common.filter_cmfs` definition.""" - self.assertListEqual( - sorted( - cmfs.name - for cmfs in filter_cmfs( - ["CIE 1931 2 Degree Standard Observer"] - ).values() - ), - [ - "CIE 1931 2 Degree Standard Observer", - ], - ) + assert sorted( + cmfs.name + for cmfs in filter_cmfs(["CIE 1931 2 Degree Standard Observer"]).values() + ) == [ + "CIE 1931 2 Degree Standard Observer", + ] -class TestFilterIlluminants(unittest.TestCase): +class TestFilterIlluminants: """ Define :func:`colour.plotting.common.filter_illuminants` definition unit tests methods. @@ -442,13 +414,10 @@ class TestFilterIlluminants(unittest.TestCase): def test_filter_illuminants(self): """Test :func:`colour.plotting.common.filter_illuminants` definition.""" - self.assertListEqual( - sorted(filter_illuminants(["D50"]).keys()), - ["D50"], - ) + assert sorted(filter_illuminants(["D50"]).keys()) == ["D50"] -class TestFilterColourCheckers(unittest.TestCase): +class TestFilterColourCheckers: """ Define :func:`colour.plotting.common.filter_colour_checkers` definition unit tests methods. @@ -457,20 +426,17 @@ class TestFilterColourCheckers(unittest.TestCase): def test_filter_colour_checkers(self): """Test :func:`colour.plotting.common.filter_colour_checkers` definition.""" - self.assertListEqual( - sorted( - colour_checker.name - for colour_checker in filter_colour_checkers( - ["ColorChecker24 - After November 2014"] - ).values() - ), - [ - "ColorChecker24 - After November 2014", - ], - ) + assert sorted( + colour_checker.name + for colour_checker in filter_colour_checkers( + ["ColorChecker24 - After November 2014"] + ).values() + ) == [ + "ColorChecker24 - After November 2014", + ] -class TestUpdateSettingsCollection(unittest.TestCase): +class TestUpdateSettingsCollection: """ Define :func:`colour.plotting.common.update_settings_collection` definition unit tests methods. @@ -485,15 +451,15 @@ def test_update_settings_collection(self): settings_collection = [{1: 2}, {3: 4}] keyword_arguments = {5: 6} update_settings_collection(settings_collection, keyword_arguments, 2) - self.assertListEqual(settings_collection, [{1: 2, 5: 6}, {3: 4, 5: 6}]) + assert settings_collection == [{1: 2, 5: 6}, {3: 4, 5: 6}] settings_collection = [{1: 2}, {3: 4}] keyword_arguments = [{5: 6}, {7: 8}] update_settings_collection(settings_collection, keyword_arguments, 2) - self.assertListEqual(settings_collection, [{1: 2, 5: 6}, {3: 4, 7: 8}]) + assert settings_collection == [{1: 2, 5: 6}, {3: 4, 7: 8}] -class TestPlotSingleColourSwatch(unittest.TestCase): +class TestPlotSingleColourSwatch: """ Define :func:`colour.plotting.common.plot_single_colour_swatch` definition unit tests methods. @@ -509,18 +475,18 @@ def test_plot_single_colour_swatch(self): ColourSwatch((0.45620519, 0.03081071, 0.04091952)) ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_single_colour_swatch( np.array([0.45620519, 0.03081071, 0.04091952]) ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotMultiColourSwatches(unittest.TestCase): +class TestPlotMultiColourSwatches: """ Define :func:`colour.plotting.common.plot_multi_colour_swatches` definition unit tests methods. @@ -539,8 +505,8 @@ def test_plot_multi_colour_swatches(self): ] ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_multi_colour_swatches( np.array( @@ -552,11 +518,11 @@ def test_plot_multi_colour_swatches(self): direction="-y", ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotSingleFunction(unittest.TestCase): +class TestPlotSingleFunction: """ Define :func:`colour.plotting.common.plot_single_function` definition unit tests methods. @@ -567,11 +533,11 @@ def test_plot_single_function(self): figure, axes = plot_single_function(partial(gamma_function, exponent=1 / 2.2)) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotMultiFunctions(unittest.TestCase): +class TestPlotMultiFunctions: """ Define :func:`colour.plotting.common.plot_multi_functions` definition unit tests methods. @@ -588,29 +554,29 @@ def test_plot_multi_functions(self): plot_kwargs = {"c": "r"} figure, axes = plot_multi_functions(functions, plot_kwargs=plot_kwargs) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) plot_kwargs = [{"c": "r"}, {"c": "g"}, {"c": "b"}] figure, axes = plot_multi_functions( functions, log_x=10, log_y=10, plot_kwargs=plot_kwargs ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_multi_functions(functions, log_x=10) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_multi_functions(functions, log_y=10) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotImage(unittest.TestCase): +class TestPlotImage: """ Define :func:`colour.plotting.common.plot_image` definition unit tests methods. @@ -630,9 +596,5 @@ def test_plot_image(self): figure, axes = plot_image(read_image(path)) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) - - -if __name__ == "__main__": - unittest.main() + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) diff --git a/colour/plotting/tests/test_corresponding.py b/colour/plotting/tests/test_corresponding.py index 5e44b0249..52a7059a6 100644 --- a/colour/plotting/tests/test_corresponding.py +++ b/colour/plotting/tests/test_corresponding.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.plotting.corresponding` module.""" -import unittest from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -20,7 +19,7 @@ ] -class TestPlotCorrespondingChromaticitiesPrediction(unittest.TestCase): +class TestPlotCorrespondingChromaticitiesPrediction: """ Define :func:`colour.plotting.corresponding.\ plot_corresponding_chromaticities_prediction` definition unit tests methods. @@ -34,9 +33,5 @@ def test_plot_corresponding_chromaticities_prediction(self): figure, axes = plot_corresponding_chromaticities_prediction() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) - - -if __name__ == "__main__": - unittest.main() + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) diff --git a/colour/plotting/tests/test_diagrams.py b/colour/plotting/tests/test_diagrams.py index 0dae92555..4b1b3132a 100644 --- a/colour/plotting/tests/test_diagrams.py +++ b/colour/plotting/tests/test_diagrams.py @@ -1,8 +1,8 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.plotting.diagrams` module.""" -import unittest +import pytest from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -50,7 +50,7 @@ ] -class TestLinesSpectralLocus(unittest.TestCase): +class TestLinesSpectralLocus: """ Define :func:`colour.plotting.diagrams.lines_spectral_locus` definition unit tests methods. @@ -62,10 +62,10 @@ def test_lines_spectral_locus(self): definition. """ - self.assertEqual(len(lines_spectral_locus()), 2) + assert len(lines_spectral_locus()) == 2 -class TestPlotSpectralLocus(unittest.TestCase): +class TestPlotSpectralLocus: """ Define :func:`colour.plotting.diagrams.plot_spectral_locus` definition unit tests methods. @@ -78,27 +78,27 @@ def test_plot_spectral_locus(self): figure, axes = plot_spectral_locus() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_spectral_locus(spectral_locus_colours="RGB") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_spectral_locus( method="CIE 1960 UCS", spectral_locus_colours="RGB" ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_spectral_locus( method="CIE 1976 UCS", spectral_locus_colours="RGB" ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_spectral_locus( reshape_msds( @@ -107,13 +107,13 @@ def test_plot_spectral_locus(self): ) ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) - self.assertRaises(ValueError, lambda: plot_spectral_locus(method="Undefined")) + pytest.raises(ValueError, lambda: plot_spectral_locus(method="Undefined")) -class TestPlotChromaticityDiagramColours(unittest.TestCase): +class TestPlotChromaticityDiagramColours: """ Define :func:`colour.plotting.diagrams.plot_chromaticity_diagram_colours` definition unit tests methods. @@ -127,21 +127,21 @@ def test_plot_chromaticity_diagram_colours(self): figure, axes = plot_chromaticity_diagram_colours() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) - self.assertRaises( + pytest.raises( ValueError, lambda: plot_chromaticity_diagram_colours(method="Undefined"), ) figure, axes = plot_chromaticity_diagram_colours(diagram_colours="RGB") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotChromaticityDiagram(unittest.TestCase): +class TestPlotChromaticityDiagram: """ Define :func:`colour.plotting.diagrams.plot_chromaticity_diagram` definition unit tests methods. @@ -155,20 +155,20 @@ def test_plot_chromaticity_diagram(self): figure, axes = plot_chromaticity_diagram() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_chromaticity_diagram(method="CIE 1960 UCS") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_chromaticity_diagram(method="CIE 1976 UCS") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) - self.assertRaises( + pytest.raises( ValueError, lambda: plot_chromaticity_diagram( method="Undefined", @@ -178,7 +178,7 @@ def test_plot_chromaticity_diagram(self): ) -class TestPlotChromaticityDiagramCIE1931(unittest.TestCase): +class TestPlotChromaticityDiagramCIE1931: """ Define :func:`colour.plotting.diagrams.plot_chromaticity_diagram_CIE1931` definition unit tests methods. @@ -192,11 +192,11 @@ def test_plot_chromaticity_diagram_CIE1931(self): figure, axes = plot_chromaticity_diagram_CIE1931() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotChromaticityDiagramCIE1960UCS(unittest.TestCase): +class TestPlotChromaticityDiagramCIE1960UCS: """ Define :func:`colour.plotting.diagrams.\ plot_chromaticity_diagram_CIE1960UCS` definition unit tests methods. @@ -210,11 +210,11 @@ def test_plot_chromaticity_diagram_CIE1960UCS(self): figure, axes = plot_chromaticity_diagram_CIE1960UCS() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotChromaticityDiagramCIE1976UCS(unittest.TestCase): +class TestPlotChromaticityDiagramCIE1976UCS: """ Define :func:`colour.plotting.diagrams.\ plot_chromaticity_diagram_CIE1976UCS` definition unit tests methods. @@ -228,11 +228,11 @@ def test_plot_chromaticity_diagram_CIE1976UCS(self): figure, axes = plot_chromaticity_diagram_CIE1976UCS() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotSdsInChromaticityDiagram(unittest.TestCase): +class TestPlotSdsInChromaticityDiagram: """ Define :func:`colour.plotting.diagrams.\ plot_sds_in_chromaticity_diagram` definition unit tests methods. @@ -250,8 +250,8 @@ def test_plot_sds_in_chromaticity_diagram(self): plot_kwargs={"normalise_sd_colours": True, "use_sd_colours": True}, ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_sds_in_chromaticity_diagram( [SDS_ILLUMINANTS["A"], SDS_ILLUMINANTS["D65"]], @@ -259,10 +259,10 @@ def test_plot_sds_in_chromaticity_diagram(self): plot_kwargs=[{"normalise_sd_colours": True, "use_sd_colours": True}] * 2, ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) - self.assertRaises( + pytest.raises( ValueError, lambda: plot_sds_in_chromaticity_diagram( [SDS_ILLUMINANTS["A"], SDS_ILLUMINANTS["D65"]], @@ -272,7 +272,7 @@ def test_plot_sds_in_chromaticity_diagram(self): ) -class TestPlotSdsInChromaticityDiagramCIE1931(unittest.TestCase): +class TestPlotSdsInChromaticityDiagramCIE1931: """ Define :func:`colour.plotting.diagrams.\ plot_sds_in_chromaticity_diagram_CIE1931` definition unit tests methods. @@ -288,11 +288,11 @@ def test_plot_sds_in_chromaticity_diagram_CIE1931(self): [SDS_ILLUMINANTS["A"], SDS_ILLUMINANTS["D65"]] ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotSdsInChromaticityDiagramCIE1960UCS(unittest.TestCase): +class TestPlotSdsInChromaticityDiagramCIE1960UCS: """ Define :func:`colour.plotting.diagrams.\ plot_sds_in_chromaticity_diagram_CIE1960UCS` definition unit tests methods. @@ -308,11 +308,11 @@ def test_plot_sds_in_chromaticity_diagram_CIE1960UCS(self): [SDS_ILLUMINANTS["A"], SDS_ILLUMINANTS["D65"]] ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotSdsInChromaticityDiagramCIE1976UCS(unittest.TestCase): +class TestPlotSdsInChromaticityDiagramCIE1976UCS: """ Define :func:`colour.plotting.diagrams.\ plot_sds_in_chromaticity_diagram_CIE1976UCS` definition unit tests methods. @@ -328,9 +328,5 @@ def test_plot_sds_in_chromaticity_diagram_CIE1976UCS(self): [SDS_ILLUMINANTS["A"], SDS_ILLUMINANTS["D65"]] ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) - - -if __name__ == "__main__": - unittest.main() + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) diff --git a/colour/plotting/tests/test_graph.py b/colour/plotting/tests/test_graph.py index 124bc6edf..56c839b1d 100644 --- a/colour/plotting/tests/test_graph.py +++ b/colour/plotting/tests/test_graph.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.plotting.graph` module.""" import tempfile -import unittest from colour.plotting import plot_automatic_colour_conversion_graph from colour.utilities import is_graphviz_installed, is_networkx_installed @@ -18,7 +17,7 @@ ] -class TestPlotAutomaticColourConversionGraph(unittest.TestCase): +class TestPlotAutomaticColourConversionGraph: """ Define :func:`colour.plotting.graph.\ plot_automatic_colour_conversion_graph` definition unit tests methods. @@ -38,7 +37,3 @@ def test_plot_automatic_colour_conversion_graph(self): plot_automatic_colour_conversion_graph( # pragma: no cover f"{tempfile.mkstemp()[-1]}.png" ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/plotting/tests/test_models.py b/colour/plotting/tests/test_models.py index 9c5d10ff3..1e74be3b0 100644 --- a/colour/plotting/tests/test_models.py +++ b/colour/plotting/tests/test_models.py @@ -1,9 +1,9 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.plotting.models` module.""" -import unittest import numpy as np +import pytest from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -61,7 +61,7 @@ ] -class TestCommonColourspaceModelAxisReorder(unittest.TestCase): +class TestCommonColourspaceModelAxisReorder: """ Define :func:`colour.plotting.models.colourspace_model_axis_reorder` definition unit tests methods. @@ -104,7 +104,7 @@ def test_colourspace_model_axis_reorder(self): ) -class TestLinesPointerGamut(unittest.TestCase): +class TestLinesPointerGamut: """ Define :func:`colour.plotting.models.lines_pointer_gamut` definition unit tests methods. @@ -115,10 +115,10 @@ def test_lines_pointer_gamut(self): Test :func:`colour.plotting.models.lines_pointer_gamut` definition. """ - self.assertEqual(len(lines_pointer_gamut()), 2) + assert len(lines_pointer_gamut()) == 2 -class TestPlotPointerGamut(unittest.TestCase): +class TestPlotPointerGamut: """ Define :func:`colour.plotting.models.plot_pointer_gamut` definition unit tests methods. @@ -129,23 +129,23 @@ def test_plot_pointer_gamut(self): figure, axes = plot_pointer_gamut() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_pointer_gamut(method="CIE 1960 UCS") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_pointer_gamut(method="CIE 1976 UCS") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) - self.assertRaises(ValueError, lambda: plot_pointer_gamut(method="Undefined")) + pytest.raises(ValueError, lambda: plot_pointer_gamut(method="Undefined")) -class TestPlotRGBColourspacesInChromaticityDiagram(unittest.TestCase): +class TestPlotRGBColourspacesInChromaticityDiagram: """ Define :func:`colour.plotting.models.\ plot_RGB_colourspaces_in_chromaticity_diagram` definition unit tests methods. @@ -164,18 +164,18 @@ def test_plot_RGB_colourspaces_in_chromaticity_diagram(self): plot_kwargs={"linestyle": "dashed"}, ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_RGB_colourspaces_in_chromaticity_diagram( ["ITU-R BT.709", "ACEScg", "S-Gamut"], plot_kwargs=[{"linestyle": "dashed"}] * 3, ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) - self.assertRaises( + pytest.raises( ValueError, lambda: plot_RGB_colourspaces_in_chromaticity_diagram( ["ITU-R BT.709", "ACEScg", "S-Gamut"], @@ -185,7 +185,7 @@ def test_plot_RGB_colourspaces_in_chromaticity_diagram(self): ) -class TestPlotRGBColourspacesInChromaticityDiagramCIE1931(unittest.TestCase): +class TestPlotRGBColourspacesInChromaticityDiagramCIE1931: """ Define :func:`colour.plotting.models.\ plot_RGB_colourspaces_in_chromaticity_diagram_CIE1931` definition unit tests @@ -202,11 +202,11 @@ def test_plot_RGB_colourspaces_in_chromaticity_diagram_CIE1931(self): ["ITU-R BT.709", "ACEScg", "S-Gamut"] ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotRGBColourspacesInChromaticityDiagramCIE1960UCS(unittest.TestCase): +class TestPlotRGBColourspacesInChromaticityDiagramCIE1960UCS: """ Define :func:`colour.plotting.models.\ plot_RGB_colourspaces_in_chromaticity_diagram_CIE1960UCS` definition unit tests @@ -226,11 +226,11 @@ def test_plot_RGB_colourspaces_in_chromaticity_diagram_CIE1960UCS(self): ["ITU-R BT.709", "ACEScg", "S-Gamut"] ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotRGBColourspacesInChromaticityDiagramCIE1976UCS(unittest.TestCase): +class TestPlotRGBColourspacesInChromaticityDiagramCIE1976UCS: """ Define :func:`colour.plotting.models.\ plot_RGB_colourspaces_in_chromaticity_diagram_CIE1976UCS` definition unit tests @@ -250,11 +250,11 @@ def test_plot_RGB_colourspaces_in_chromaticity_diagram_CIE1976UCS(self): ["ITU-R BT.709", "ACEScg", "S-Gamut"] ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotRGBChromaticitiesInChromaticityDiagram(unittest.TestCase): +class TestPlotRGBChromaticitiesInChromaticityDiagram: """ Define :func:`colour.plotting.models.\ plot_RGB_chromaticities_in_chromaticity_diagram` definition unit tests methods. @@ -270,11 +270,11 @@ def test_plot_RGB_chromaticities_in_chromaticity_diagram(self): np.random.random((128, 128, 3)), scatter_kwargs={"marker": "v"} ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotRGBChromaticitiesInChromaticityDiagramCIE1931(unittest.TestCase): +class TestPlotRGBChromaticitiesInChromaticityDiagramCIE1931: """ Define :func:`colour.plotting.models.\ plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931` definition unit tests @@ -291,11 +291,11 @@ def test_plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931(self): np.random.random((128, 128, 3)) ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotRGBChromaticitiesInChromaticityDiagramCIE1960UCS(unittest.TestCase): +class TestPlotRGBChromaticitiesInChromaticityDiagramCIE1960UCS: """ Define :func:`colour.plotting.models.\ plot_RGB_chromaticities_in_chromaticity_diagram_CIE1960UCS` definition unit @@ -315,11 +315,11 @@ def test_plot_RGB_chromaticities_in_chromaticity_diagram_CIE1960UCS(self): np.random.random((128, 128, 3)) ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotRGBChromaticitiesInChromaticityDiagramCIE1976UCS(unittest.TestCase): +class TestPlotRGBChromaticitiesInChromaticityDiagramCIE1976UCS: """ Define :func:`colour.plotting.models.\ plot_RGB_chromaticities_in_chromaticity_diagram_CIE1976UCS` definition unit @@ -339,11 +339,11 @@ def test_plot_RGB_chromaticities_in_chromaticity_diagram_CIE1976UCS(self): np.random.random((128, 128, 3)) ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestEllipsesMacAdam1942(unittest.TestCase): +class TestEllipsesMacAdam1942: """ Define :func:`colour.plotting.models.ellipses_MacAdam1942` definition unit tests methods. @@ -352,12 +352,12 @@ class TestEllipsesMacAdam1942(unittest.TestCase): def test_ellipses_MacAdam1942(self): """Test :func:`colour.plotting.models.ellipses_MacAdam1942` definition.""" - self.assertEqual(len(ellipses_MacAdam1942()), 25) + assert len(ellipses_MacAdam1942()) == 25 - self.assertRaises(ValueError, lambda: ellipses_MacAdam1942(method="Undefined")) + pytest.raises(ValueError, lambda: ellipses_MacAdam1942(method="Undefined")) -class TestPlotEllipsesMacAdam1942InChromaticityDiagram(unittest.TestCase): +class TestPlotEllipsesMacAdam1942InChromaticityDiagram: """ Define :func:`colour.plotting.models.\ plot_ellipses_MacAdam1942_in_chromaticity_diagram` definition unit tests @@ -374,19 +374,19 @@ def test_plot_ellipses_MacAdam1942_in_chromaticity_diagram(self): chromaticity_diagram_clipping=True, ellipse_kwargs={"color": "k"} ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_ellipses_MacAdam1942_in_chromaticity_diagram( chromaticity_diagram_clipping=True, ellipse_kwargs=[{"color": "k"}] * 25, ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotEllipsesMacAdam1942InChromaticityDiagramCIE1931(unittest.TestCase): +class TestPlotEllipsesMacAdam1942InChromaticityDiagramCIE1931: """ Define :func:`colour.plotting.models.\ plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1931` definition unit @@ -404,11 +404,11 @@ def test_plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1931(self): axes, ) = plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1931() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotEllipsesMacAdam1942InChromaticityDiagramCIE1960UCS(unittest.TestCase): +class TestPlotEllipsesMacAdam1942InChromaticityDiagramCIE1960UCS: """ Define :func:`colour.plotting.models.\ plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1960UCS` definition unit @@ -428,11 +428,11 @@ def test_plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1960UCS( axes, ) = plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1960UCS() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotEllipsesMacAdam1942InChromaticityDiagramCIE1976UCS(unittest.TestCase): +class TestPlotEllipsesMacAdam1942InChromaticityDiagramCIE1976UCS: """ Define :func:`colour.plotting.models.\ plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1976UCS` definition unit @@ -452,11 +452,11 @@ def test_plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1976UCS( axes, ) = plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1976UCS() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotSingleCctf(unittest.TestCase): +class TestPlotSingleCctf: """ Define :func:`colour.plotting.models.plot_single_cctf` definition unit tests methods. @@ -467,11 +467,11 @@ def test_plot_single_cctf(self): figure, axes = plot_single_cctf("ITU-R BT.709") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotMultiCctfs(unittest.TestCase): +class TestPlotMultiCctfs: """ Define :func:`colour.plotting.models.plot_multi_cctfs` definition unit tests methods. @@ -482,11 +482,11 @@ def test_plot_multi_cctfs(self): figure, axes = plot_multi_cctfs(["ITU-R BT.709", "sRGB"]) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotConstantHueLoci(unittest.TestCase): +class TestPlotConstantHueLoci: """ Define :func:`colour.plotting.models.plot_constant_hue_loci` definition unit tests methods. @@ -573,9 +573,5 @@ def test_plot_constant_hue_loci(self): data, "IPT", scatter_kwargs={"marker": "v"} ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) - - -if __name__ == "__main__": - unittest.main() + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) diff --git a/colour/plotting/tests/test_notation.py b/colour/plotting/tests/test_notation.py index 0aac91859..2f6f550be 100644 --- a/colour/plotting/tests/test_notation.py +++ b/colour/plotting/tests/test_notation.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.plotting.notation` module.""" -import unittest from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -24,7 +23,7 @@ ] -class TestPlotSingleMunsellValueFunction(unittest.TestCase): +class TestPlotSingleMunsellValueFunction: """ Define :func:`colour.plotting.notation.plot_single_munsell_value_function` definition unit tests methods. @@ -38,11 +37,11 @@ def test_plot_single_munsell_value_function(self): figure, axes = plot_single_munsell_value_function("ASTM D1535") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotMultiMunsellValueFunctions(unittest.TestCase): +class TestPlotMultiMunsellValueFunctions: """ Define :func:`colour.plotting.notation.plot_multi_munsell_value_functions` definition unit tests methods. @@ -56,9 +55,5 @@ def test_plot_multi_munsell_value_functions(self): figure, axes = plot_multi_munsell_value_functions(["ASTM D1535", "McCamy 1987"]) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) - - -if __name__ == "__main__": - unittest.main() + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) diff --git a/colour/plotting/tests/test_phenomena.py b/colour/plotting/tests/test_phenomena.py index 06d977780..c10007a83 100644 --- a/colour/plotting/tests/test_phenomena.py +++ b/colour/plotting/tests/test_phenomena.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.plotting.phenomena` module.""" -import unittest from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -24,7 +23,7 @@ ] -class TestPlotSingleSdRayleighScattering(unittest.TestCase): +class TestPlotSingleSdRayleighScattering: """ Define :func:`colour.plotting.phenomena.\ plot_single_sd_rayleigh_scattering` definition unit tests methods. @@ -38,11 +37,11 @@ def test_plot_single_sd_rayleigh_scattering(self): figure, axes = plot_single_sd_rayleigh_scattering() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotTheBlueSky(unittest.TestCase): +class TestPlotTheBlueSky: """ Define :func:`colour.plotting.phenomena.plot_the_blue_sky` definition unit tests methods. @@ -53,9 +52,5 @@ def test_plot_the_blue_sky(self): figure, axes = plot_the_blue_sky() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) - - -if __name__ == "__main__": - unittest.main() + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) diff --git a/colour/plotting/tests/test_quality.py b/colour/plotting/tests/test_quality.py index 8802ff08c..98ad2ecc9 100644 --- a/colour/plotting/tests/test_quality.py +++ b/colour/plotting/tests/test_quality.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.plotting.quality` module.""" -import unittest from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -37,7 +36,7 @@ ] -class TestPlotColourQualityBars(unittest.TestCase): +class TestPlotColourQualityBars: """ Define :func:`colour.plotting.quality.plot_colour_quality_bars` definition unit tests methods. @@ -57,11 +56,11 @@ def test_plot_colour_quality_bars(self): figure, axes = plot_colour_quality_bars([cqs_i, cqs_l]) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotSingleSdColourRenderingIndexBars(unittest.TestCase): +class TestPlotSingleSdColourRenderingIndexBars: """ Define :func:`colour.plotting.quality.\ plot_single_sd_colour_rendering_index_bars` definition unit tests methods. @@ -77,11 +76,11 @@ def test_plot_single_sd_colour_rendering_index_bars(self): SDS_ILLUMINANTS["FL2"] ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotMultiSdsColourRenderingIndexesBars(unittest.TestCase): +class TestPlotMultiSdsColourRenderingIndexesBars: """ Define :func:`colour.plotting.quality.\ plot_multi_sds_colour_rendering_indexes_bars` definition unit tests methods. @@ -97,11 +96,11 @@ def test_plot_multi_sds_colour_rendering_indexes_bars(self): [SDS_ILLUMINANTS["FL2"], SDS_LIGHT_SOURCES["Kinoton 75P"]] ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotSingleSdColourQualityScaleBars(unittest.TestCase): +class TestPlotSingleSdColourQualityScaleBars: """ Define :func:`colour.plotting.quality.\ plot_single_sd_colour_quality_scale_bars` definition unit tests methods. @@ -115,11 +114,11 @@ def test_plot_single_sd_colour_quality_scale_bars(self): figure, axes = plot_single_sd_colour_quality_scale_bars(SDS_ILLUMINANTS["FL2"]) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotMultiSdsColourQualityScalesBars(unittest.TestCase): +class TestPlotMultiSdsColourQualityScalesBars: """ Define :func:`colour.plotting.quality.\ plot_multi_sds_colour_quality_scales_bars` definition unit tests methods. @@ -135,9 +134,5 @@ def test_plot_multi_sds_colour_quality_scales_bars(self): [SDS_ILLUMINANTS["FL2"], SDS_LIGHT_SOURCES["Kinoton 75P"]] ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) - - -if __name__ == "__main__": - unittest.main() + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) diff --git a/colour/plotting/tests/test_section.py b/colour/plotting/tests/test_section.py index 185b0baa3..1edacd9c8 100644 --- a/colour/plotting/tests/test_section.py +++ b/colour/plotting/tests/test_section.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.plotting.section` module.""" -import unittest from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -33,7 +32,7 @@ ] -class TestPlotHullSectionColours(unittest.TestCase): +class TestPlotHullSectionColours: """ Define :func:`colour.plotting.section.plot_hull_section_colours` definition unit tests methods. @@ -56,21 +55,21 @@ def test_plot_hull_section_colours(self): figure, axes = plot_hull_section_colours(hull) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_hull_section_colours(hull, axis="+x") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_hull_section_colours(hull, axis="+y") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotHullSectionContour(unittest.TestCase): +class TestPlotHullSectionContour: """ Define :func:`colour.plotting.section.plot_hull_section_contour` definition unit tests methods. @@ -93,11 +92,11 @@ def test_plot_hull_section_contour(self): figure, axes = plot_hull_section_contour(hull) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotVisibleSpectrumSection(unittest.TestCase): +class TestPlotVisibleSpectrumSection: """ Define :func:`colour.plotting.section.plot_visible_spectrum_section` definition unit tests methods. @@ -114,11 +113,11 @@ def test_plot_visible_spectrum_section(self): figure, axes = plot_visible_spectrum_section() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotRGBColourspaceSection(unittest.TestCase): +class TestPlotRGBColourspaceSection: """ Define :func:`colour.plotting.section.plot_RGB_colourspace_section` definition unit tests methods. @@ -135,9 +134,5 @@ def test_plot_RGB_colourspace_section(self): figure, axes = plot_RGB_colourspace_section("sRGB") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) - - -if __name__ == "__main__": - unittest.main() + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) diff --git a/colour/plotting/tests/test_temperature.py b/colour/plotting/tests/test_temperature.py index 2fd3dc015..add12654b 100644 --- a/colour/plotting/tests/test_temperature.py +++ b/colour/plotting/tests/test_temperature.py @@ -1,8 +1,8 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.plotting.temperature` module.""" -import unittest +import pytest from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -36,7 +36,7 @@ ] -class TestLinesDaylightLocus(unittest.TestCase): +class TestLinesDaylightLocus: """ Define :func:`colour.plotting.diagrams.lines_daylight_locus` definition unit tests methods. @@ -47,10 +47,10 @@ def test_lines_daylight_locus(self): Test :func:`colour.plotting.diagrams.lines_daylight_locus` definition. """ - self.assertEqual(len(lines_daylight_locus()), 1) + assert len(lines_daylight_locus()) == 1 -class TestPlotDaylightLocus(unittest.TestCase): +class TestPlotDaylightLocus: """ Define :func:`colour.plotting.temperature.plot_daylight_locus` definition unit tests methods. @@ -64,23 +64,23 @@ def test_plot_daylight_locus(self): figure, axes = plot_daylight_locus() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) - self.assertRaises(ValueError, lambda: plot_daylight_locus(method="Undefined")) + pytest.raises(ValueError, lambda: plot_daylight_locus(method="Undefined")) figure, axes = plot_daylight_locus(method="CIE 1976 UCS") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_daylight_locus(planckian_locus_colours="RGB") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestLinesPlanckianLocus(unittest.TestCase): +class TestLinesPlanckianLocus: """ Define :func:`colour.plotting.diagrams.lines_planckian_locus` definition unit tests methods. @@ -91,10 +91,10 @@ def test_lines_planckian_locus(self): Test :func:`colour.plotting.diagrams.lines_planckian_locus` definition. """ - self.assertEqual(len(lines_planckian_locus()), 2) + assert len(lines_planckian_locus()) == 2 -class TestPlotPlanckianLocus(unittest.TestCase): +class TestPlotPlanckianLocus: """ Define :func:`colour.plotting.temperature.plot_planckian_locus` definition unit tests methods. @@ -108,28 +108,28 @@ def test_plot_planckian_locus(self): figure, axes = plot_planckian_locus() - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) - self.assertRaises(ValueError, lambda: plot_planckian_locus(method="Undefined")) + pytest.raises(ValueError, lambda: plot_planckian_locus(method="Undefined")) figure, axes = plot_planckian_locus(method="CIE 1976 UCS") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_planckian_locus(planckian_locus_colours="RGB") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_planckian_locus(planckian_locus_labels=[5500, 6500]) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotPlanckianLocusInChromaticityDiagram(unittest.TestCase): +class TestPlotPlanckianLocusInChromaticityDiagram: """ Define :func:`colour.plotting.temperature.\ plot_planckian_locus_in_chromaticity_diagram` definition unit tests methods. @@ -149,8 +149,8 @@ def test_plot_planckian_locus_in_chromaticity_diagram(self): }, ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) figure, axes = plot_planckian_locus_in_chromaticity_diagram( ["A", "B", "C"], @@ -163,10 +163,10 @@ def test_plot_planckian_locus_in_chromaticity_diagram(self): * 3, ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) - self.assertRaises( + pytest.raises( ValueError, lambda: plot_planckian_locus_in_chromaticity_diagram( ["A", "B", "C"], @@ -177,7 +177,7 @@ def test_plot_planckian_locus_in_chromaticity_diagram(self): ) -class TestPlotPlanckianLocusInChromaticityDiagramCIE1931(unittest.TestCase): +class TestPlotPlanckianLocusInChromaticityDiagramCIE1931: """ Define :func:`colour.plotting.temperature.\ plot_planckian_locus_in_chromaticity_diagram_CIE1931` definition unit tests @@ -194,11 +194,11 @@ def test_plot_planckian_locus_in_chromaticity_diagram_CIE1931(self): ["A", "B", "C"] ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotPlanckianLocusInChromaticityDiagramCIE1960UCS(unittest.TestCase): +class TestPlotPlanckianLocusInChromaticityDiagramCIE1960UCS: """ Define :func:`colour.plotting.temperature.\ plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS` definition unit tests @@ -215,9 +215,5 @@ def test_plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS(self): ["A", "B", "C"] ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) - - -if __name__ == "__main__": - unittest.main() + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) diff --git a/colour/plotting/tests/test_volume.py b/colour/plotting/tests/test_volume.py index 240fae10e..3697dd334 100644 --- a/colour/plotting/tests/test_volume.py +++ b/colour/plotting/tests/test_volume.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.plotting.volume` module.""" -import unittest import numpy as np from matplotlib.axes import Axes @@ -26,7 +25,7 @@ ] -class TestNadirGrid(unittest.TestCase): +class TestNadirGrid: """ Define :func:`colour.plotting.volume.nadir_grid` definition unit tests methods. @@ -121,7 +120,7 @@ def test_nadir_grid(self): ) -class TestRGBIdentityCube(unittest.TestCase): +class TestRGBIdentityCube: """ Define :func:`colour.plotting.volume.RGB_identity_cube` definition unit tests methods. @@ -193,7 +192,7 @@ def test_RGB_identity_cube(self): ) -class TestPlotRGBColourspacesGamuts(unittest.TestCase): +class TestPlotRGBColourspacesGamuts: """ Define :func:`colour.plotting.volume.plot_RGB_colourspaces_gamuts` definition unit tests methods. @@ -212,11 +211,11 @@ def test_plot_RGB_colourspaces_gamuts(self): chromatically_adapt=True, ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotRGBScatter(unittest.TestCase): +class TestPlotRGBScatter: """ Define :func:`colour.plotting.volume.plot_RGB_scatter` definition unit tests methods. @@ -227,9 +226,5 @@ def test_plot_RGB_scatter(self): figure, axes = plot_RGB_scatter(np.random.random((128, 128, 3)), "ITU-R BT.709") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) - - -if __name__ == "__main__": - unittest.main() + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) diff --git a/colour/plotting/tm3018/tests/test_components.py b/colour/plotting/tm3018/tests/test_components.py index 2aa190cf6..14c3ec282 100644 --- a/colour/plotting/tm3018/tests/test_components.py +++ b/colour/plotting/tm3018/tests/test_components.py @@ -3,8 +3,6 @@ from __future__ import annotations -import unittest - from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -47,7 +45,7 @@ ) -class TestPlotSpectraANSIIESTM3018(unittest.TestCase): +class TestPlotSpectraANSIIESTM3018: """ Define :func:`colour.plotting.tm3018.components. plot_spectra_ANSIIESTM3018` definition unit tests methods. @@ -61,11 +59,11 @@ def test_plot_spectra_ANSIIESTM3018(self): figure, axes = plot_spectra_ANSIIESTM3018(SPECIFICATION_ANSIIESTM3018) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotColourVectorGraphic(unittest.TestCase): +class TestPlotColourVectorGraphic: """ Define :func:`colour.plotting.tm3018.components.\ plot_colour_vector_graphic` definition unit tests methods. @@ -79,11 +77,11 @@ def test_plot_colour_vector_graphic(self): figure, axes = plot_colour_vector_graphic(SPECIFICATION_ANSIIESTM3018) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlot16BinBars(unittest.TestCase): +class TestPlot16BinBars: """ Define :func:`colour.plotting.tm3018.components.plot_16_bin_bars` definition unit tests methods. @@ -97,11 +95,11 @@ def test_plot_16_bin_bars(self): figure, axes = plot_16_bin_bars(range(16), "{0}") - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotLocalChromaShifts(unittest.TestCase): +class TestPlotLocalChromaShifts: """ Define :func:`colour.plotting.tm3018.components.plot_local_chroma_shifts` definition unit tests methods. @@ -115,11 +113,11 @@ def test_plot_local_chroma_shifts(self): figure, axes = plot_local_chroma_shifts(SPECIFICATION_ANSIIESTM3018) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotLocalHueShifts(unittest.TestCase): +class TestPlotLocalHueShifts: """ Define :func:`colour.plotting.tm3018.components.plot_local_hue_shifts` definition unit tests methods. @@ -133,11 +131,11 @@ def test_plot_local_hue_shifts(self): figure, axes = plot_local_hue_shifts(SPECIFICATION_ANSIIESTM3018) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotLocalColourFidelities(unittest.TestCase): +class TestPlotLocalColourFidelities: """ Define :func:`colour.plotting.tm3018.components. plot_local_colour_fidelities` definition unit tests methods. @@ -151,11 +149,11 @@ def test_plot_local_colour_fidelities(self): figure, axes = plot_local_colour_fidelities(SPECIFICATION_ANSIIESTM3018) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotColourFidelityIndexes(unittest.TestCase): +class TestPlotColourFidelityIndexes: """ Define :func:`colour.plotting.tm3018.components.\ plot_colour_fidelity_indexes` definition unit tests methods. @@ -169,9 +167,5 @@ def test_plot_colour_fidelity_indexes(self): figure, axes = plot_colour_fidelity_indexes(SPECIFICATION_ANSIIESTM3018) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) - - -if __name__ == "__main__": - unittest.main() + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) diff --git a/colour/plotting/tm3018/tests/test_report.py b/colour/plotting/tm3018/tests/test_report.py index 9afbd4785..b0583e70d 100644 --- a/colour/plotting/tm3018/tests/test_report.py +++ b/colour/plotting/tm3018/tests/test_report.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.plotting.tm3018.report` module.""" -import unittest from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -29,7 +28,7 @@ ] -class TestPlotSingleSdColourRenditionReportFull(unittest.TestCase): +class TestPlotSingleSdColourRenditionReportFull: """ Define :func:`colour.plotting.tm3018.report.\ plot_single_sd_colour_rendition_report_full` definition unit tests methods. @@ -45,11 +44,11 @@ def test_plot_single_sd_colour_rendition_report_full(self): SDS_ILLUMINANTS["FL2"] ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotSingleSdColourRenditionReportIntermediate(unittest.TestCase): +class TestPlotSingleSdColourRenditionReportIntermediate: """ Define :func:`colour.plotting.tm3018.report.\ plot_single_sd_colour_rendition_report_intermediate` definition unit tests @@ -66,11 +65,11 @@ def test_plot_single_sd_colour_rendition_report_intermediate(self): SDS_ILLUMINANTS["FL2"] ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotSingleSdColourRenditionReportSimple(unittest.TestCase): +class TestPlotSingleSdColourRenditionReportSimple: """ Define :func:`colour.plotting.tm3018.report.\ plot_single_sd_colour_rendition_report_simple` definition unit tests methods. @@ -86,11 +85,11 @@ def test_plot_color_vector_graphic(self): SDS_ILLUMINANTS["FL2"] ) - self.assertIsInstance(figure, Figure) - self.assertIsInstance(axes, Axes) + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) -class TestPlotSingleSdColourRenditionReport(unittest.TestCase): +class TestPlotSingleSdColourRenditionReport: """ Define :func:`colour.plotting.tm3018.report.\ plot_single_sd_colour_rendition_report` definition unit tests methods. @@ -104,9 +103,5 @@ 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) - - -if __name__ == "__main__": - unittest.main() + assert isinstance(figure, Figure) + assert isinstance(axes, Axes) diff --git a/colour/quality/tests/test_cfi2017.py b/colour/quality/tests/test_cfi2017.py index d0052d338..d44ee3242 100644 --- a/colour/quality/tests/test_cfi2017.py +++ b/colour/quality/tests/test_cfi2017.py @@ -9,9 +9,8 @@ from __future__ import annotations -import unittest - import numpy as np +import pytest from colour.colorimetry import ( SDS_ILLUMINANTS, @@ -537,7 +536,7 @@ SD_SAMPLE_1NM: SpectralDistribution = SpectralDistribution(DATA_SD_SAMPLE_1NM) -class TestColourFidelityIndexCIE2017(unittest.TestCase): +class TestColourFidelityIndexCIE2017: """ Define :func:`colour.quality.CIE2017.colour_fidelity_index_CIE2017` definition unit tests methods. @@ -885,13 +884,13 @@ def test_raise_exception_colour_fidelity_index_CFI2017(self): """ sd = reshape_sd(SDS_ILLUMINANTS["FL2"], SpectralShape(400, 700, 5)) - self.assertWarns(ColourUsageWarning, colour_fidelity_index_CIE2017, sd) + pytest.warns(ColourUsageWarning, colour_fidelity_index_CIE2017, sd) sd = reshape_sd(SDS_ILLUMINANTS["FL2"], SpectralShape(380, 780, 10)) - self.assertRaises(ValueError, colour_fidelity_index_CIE2017, sd) + pytest.raises(ValueError, colour_fidelity_index_CIE2017, sd) -class TestCctReferenceIlluminant(unittest.TestCase): +class TestCctReferenceIlluminant: """ Define :func:`colour.quality.CIE2017.CCT_reference_illuminant` definition unit tests methods. @@ -909,7 +908,7 @@ def test_CCT_reference_illuminant(self): np.testing.assert_allclose(D_uv, -0.000300000000000, atol=0.0005) -class TestSdReferenceIlluminant(unittest.TestCase): +class TestSdReferenceIlluminant: """ Define :func:`colour.quality.CIE2017.sd_reference_illuminant` definition unit tests methods. @@ -933,7 +932,3 @@ def test_sd_reference_illuminant(self): sd_blackbody(3288, shape).values, atol=1.75, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/quality/tests/test_cqs.py b/colour/quality/tests/test_cqs.py index 37ee73741..6726b5187 100644 --- a/colour/quality/tests/test_cqs.py +++ b/colour/quality/tests/test_cqs.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.quality.cqs` module.""" -import unittest import numpy as np @@ -25,7 +24,7 @@ ] -class TestColourQualityScale(unittest.TestCase): +class TestColourQualityScale: """ Define :func:`colour.quality.cqs.colour_quality_scale` definition unit tests methods. @@ -711,7 +710,3 @@ def test_colour_quality_scale(self): [data.Q_a for _index, data in sorted(specification_t.Q_as.items())], atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/quality/tests/test_cri.py b/colour/quality/tests/test_cri.py index f221d4a73..1c0ef54cc 100644 --- a/colour/quality/tests/test_cri.py +++ b/colour/quality/tests/test_cri.py @@ -3,8 +3,6 @@ from __future__ import annotations -import unittest - import numpy as np from colour.colorimetry import SDS_ILLUMINANTS, SpectralDistribution @@ -111,7 +109,7 @@ } -class TestColourRenderingIndex(unittest.TestCase): +class TestColourRenderingIndex: """ Define :func:`colour.quality.cri.colour_rendering_index` definition unit tests methods. @@ -348,7 +346,3 @@ def test_colour_rendering_index(self): [data.Q_a for _index, data in sorted(specification_t.Q_as.items())], atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/quality/tests/test_ssi.py b/colour/quality/tests/test_ssi.py index 0f291160a..c88bbacf7 100644 --- a/colour/quality/tests/test_ssi.py +++ b/colour/quality/tests/test_ssi.py @@ -3,8 +3,6 @@ from __future__ import annotations -import unittest - import numpy as np from colour.colorimetry import SDS_ILLUMINANTS, SpectralDistribution @@ -556,7 +554,7 @@ } -class TestSpectralSimilarityIndex(unittest.TestCase): +class TestSpectralSimilarityIndex: """ Define :func:`colour.quality.ssi.spectral_similarity_index` definition unit tests methods. @@ -565,15 +563,15 @@ class TestSpectralSimilarityIndex(unittest.TestCase): def test_spectral_similarity_index(self): """Test :func:`colour.quality.ssi.spectral_similarity_index` definition.""" - self.assertEqual( - spectral_similarity_index(SDS_ILLUMINANTS["C"], SDS_ILLUMINANTS["D65"]), - 94.0, + assert ( + spectral_similarity_index(SDS_ILLUMINANTS["C"], SDS_ILLUMINANTS["D65"]) + == 94.0 ) - self.assertEqual( + assert ( spectral_similarity_index( SpectralDistribution(DATA_HMI), SDS_ILLUMINANTS["D50"] - ), - 72.0, + ) + == 72.0 ) def test_spectral_similarity_rounding(self): @@ -601,7 +599,3 @@ def test_spectral_similarity_rounding(self): 71.775, atol=0.01, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/quality/tests/test_tm3018.py b/colour/quality/tests/test_tm3018.py index 11b351065..2242ce5ad 100644 --- a/colour/quality/tests/test_tm3018.py +++ b/colour/quality/tests/test_tm3018.py @@ -8,7 +8,6 @@ http://media.ies.org/docs/errata/TM-30-18_tools_etc.zip. """ -import unittest import numpy as np @@ -32,7 +31,7 @@ ] -class TestColourFidelityIndexANSIIESTM3018(unittest.TestCase): +class TestColourFidelityIndexANSIIESTM3018: """ Define :func:`colour.quality.tm3018.colour_fidelity_index_ANSIIESTM3018` definition unit tests methods. @@ -193,7 +192,7 @@ def test_colour_fidelity_index_ANSIIESTM3018(self): ) -class TestAveragesArea(unittest.TestCase): +class TestAveragesArea: """ Define :func:`colour.quality.tm3018.averages_area` definition unit tests methods. @@ -209,7 +208,3 @@ def test_averages_area(self): # Concave polygon. poly = np.array([[1.0, -1], [1, 1], [3, 1], [3, 3], [-1, 3], [-1, -1]]) np.allclose(averages_area(poly), 12) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/recovery/tests/test__init__.py b/colour/recovery/tests/test__init__.py index 522faa480..5f278d883 100644 --- a/colour/recovery/tests/test__init__.py +++ b/colour/recovery/tests/test__init__.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.recovery` module.""" -import unittest import numpy as np @@ -29,13 +28,13 @@ ] -class TestXYZ_to_sd(unittest.TestCase): +class TestXYZ_to_sd: """ Define :func:`colour.recovery.XYZ_to_sd` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._cmfs = reshape_msds( @@ -86,7 +85,3 @@ def test_domain_range_scale_XYZ_to_sd(self): value * factor_b, atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/recovery/tests/test_jakob2019.py b/colour/recovery/tests/test_jakob2019.py index 890fe39b9..efadf561a 100644 --- a/colour/recovery/tests/test_jakob2019.py +++ b/colour/recovery/tests/test_jakob2019.py @@ -4,9 +4,9 @@ import os import shutil import tempfile -import unittest import numpy as np +import pytest from colour.characterisation import SDS_COLOURCHECKERS from colour.colorimetry import handle_spectral_arguments, sd_to_XYZ @@ -42,13 +42,13 @@ ] -class TestErrorFunction(unittest.TestCase): +class TestErrorFunction: """ Define :func:`colour.recovery.jakob2019.error_function` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._shape = SPECTRAL_SHAPE_JAKOB2019 @@ -102,8 +102,8 @@ def test_intermediates(self): np.testing.assert_allclose(sd.values, R, atol=TOLERANCE_ABSOLUTE_TESTS) np.testing.assert_allclose(XYZ, sd_XYZ, atol=TOLERANCE_ABSOLUTE_TESTS) - self.assertLess(abs(error_reference - error), JND_CIE1976 / 100) - self.assertLess(delta_E_CIE1976(Lab, sd_Lab), JND_CIE1976 / 100) + assert abs(error_reference - error) < JND_CIE1976 / 100 + assert delta_E_CIE1976(Lab, sd_Lab) < JND_CIE1976 / 100 def test_derivatives(self): """ @@ -140,13 +140,13 @@ def test_derivatives(self): ) -class TestXYZ_to_sd_Jakob2019(unittest.TestCase): +class TestXYZ_to_sd_Jakob2019: """ Define :func:`colour.recovery.jakob2019.XYZ_to_sd_Jakob2019` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._shape = SPECTRAL_SHAPE_JAKOB2019 @@ -164,7 +164,7 @@ def test_XYZ_to_sd_Jakob2019(self): ) if error > JND_CIE1976 / 100: # pragma: no cover - self.fail(f"Delta E for '{name}' is {error}!") + pytest.fail(f"Delta E for '{name}' is {error}!") def test_domain_range_scale_XYZ_to_sd_Jakob2019(self): """ @@ -193,7 +193,7 @@ def test_domain_range_scale_XYZ_to_sd_Jakob2019(self): ) -class TestLUT3D_Jakob2019(unittest.TestCase): +class TestLUT3D_Jakob2019: """ Define :class:`colour.recovery.jakob2019.LUT3D_Jakob2019` definition unit tests methods. @@ -235,7 +235,7 @@ def test_required_attributes(self): ) for attribute in required_attributes: - self.assertIn(attribute, dir(LUT3D_Jakob2019)) + assert attribute in dir(LUT3D_Jakob2019) def test_required_methods(self): """Test the presence of required methods.""" @@ -250,12 +250,12 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(LUT3D_Jakob2019)) + assert method in dir(LUT3D_Jakob2019) def test_size(self): """Test :attr:`colour.recovery.jakob2019.LUT3D_Jakob2019.size` property.""" - self.assertEqual(TestLUT3D_Jakob2019.generate_LUT().size, 5) + assert TestLUT3D_Jakob2019.generate_LUT().size == 5 def test_lightness_scale(self): """ @@ -275,10 +275,7 @@ def test_coefficients(self): property. """ - self.assertTupleEqual( - TestLUT3D_Jakob2019.generate_LUT().coefficients.shape, - (3, 5, 5, 5, 3), - ) + assert TestLUT3D_Jakob2019.generate_LUT().coefficients.shape == (3, 5, 5, 5, 3) def test_LUT3D_Jakob2019(self): """ @@ -326,7 +323,7 @@ def test_LUT3D_Jakob2019(self): error = delta_E_CIE1976(Lab, recovered_Lab) if error > 2 * JND_CIE1976 / 100: # pragma: no cover - self.fail( + pytest.fail( f"Delta E for RGB={RGB} in colourspace " f"{self._RGB_colourspace.name} is {error}!" ) @@ -339,7 +336,7 @@ def test_raise_exception_RGB_to_coefficients(self): LUT = LUT3D_Jakob2019() - self.assertRaises(ValueError, LUT.RGB_to_coefficients, np.array([])) + pytest.raises(ValueError, LUT.RGB_to_coefficients, np.array([])) def test_raise_exception_read(self): """ @@ -348,8 +345,4 @@ def test_raise_exception_read(self): """ LUT = LUT3D_Jakob2019() - self.assertRaises(ValueError, LUT.read, __file__) - - -if __name__ == "__main__": - unittest.main() + pytest.raises(ValueError, LUT.read, __file__) diff --git a/colour/recovery/tests/test_jiang2013.py b/colour/recovery/tests/test_jiang2013.py index 6efe2f5ef..3e966b16d 100644 --- a/colour/recovery/tests/test_jiang2013.py +++ b/colour/recovery/tests/test_jiang2013.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.recovery.jiang2013` module.""" -import unittest import numpy as np @@ -38,13 +37,13 @@ __all__ = [ "TestPCA_Jiang2013", - "TestMixinJiang2013", + "MixinTestJiang2013", "TestRGB_to_sd_camera_sensitivity_Jiang2013", "TestRGB_to_msds_camera_sensitivities_Jiang2013", ] -class TestPCA_Jiang2013(unittest.TestCase): +class TestPCA_Jiang2013: """ Define :func:`colour.recovery.jiang2013.PCA_Jiang2013` definition unit tests methods. @@ -182,7 +181,7 @@ def test_PCA_Jiang2013(self): ) -class TestMixinJiang2013: +class MixinTestJiang2013: """A mixin for testing the :mod:`colour.recovery.jiang2013` module.""" def __init__(self) -> None: @@ -210,16 +209,16 @@ def __init__(self) -> None: ) -class TestRGB_to_sd_camera_sensitivity_Jiang2013(unittest.TestCase, TestMixinJiang2013): +class TestRGB_to_sd_camera_sensitivity_Jiang2013(MixinTestJiang2013): """ Define :func:`colour.recovery.jiang2013.RGB_to_sd_camera_sensitivity_Jiang2013` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" - TestMixinJiang2013.__init__(self) + MixinTestJiang2013.__init__(self) def test_RGB_to_sd_camera_sensitivity_Jiang2013(self): """ @@ -276,18 +275,16 @@ def test_RGB_to_sd_camera_sensitivity_Jiang2013(self): ) -class TestRGB_to_msds_camera_sensitivities_Jiang2013( - unittest.TestCase, TestMixinJiang2013 -): +class TestRGB_to_msds_camera_sensitivities_Jiang2013(MixinTestJiang2013): """ Define :func:`colour.recovery.jiang2013.\ RGB_to_msds_camera_sensitivities_Jiang2013` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" - TestMixinJiang2013.__init__(self) + MixinTestJiang2013.__init__(self) def test_RGB_to_msds_camera_sensitivities_Jiang2013(self): """ @@ -340,7 +337,3 @@ def test_RGB_to_msds_camera_sensitivities_Jiang2013(self): ), atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/recovery/tests/test_mallett2019.py b/colour/recovery/tests/test_mallett2019.py index 5e7757efd..3e313392a 100644 --- a/colour/recovery/tests/test_mallett2019.py +++ b/colour/recovery/tests/test_mallett2019.py @@ -1,9 +1,9 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.recovery.mallett2019` module.""" -import unittest import numpy as np +import pytest from colour.characterisation import SDS_COLOURCHECKERS from colour.colorimetry import ( @@ -36,13 +36,13 @@ __status__ = "Production" __all__ = [ - "TestMixinMallett2019", + "MixinTestMallett2019", "TestSpectralPrimaryDecompositionMallett2019", "TestRGB_to_sd_Mallett2019", ] -class TestMixinMallett2019: +class MixinTestMallett2019: """A mixin for testing the :mod:`colour.recovery.mallett2019` module.""" def __init__(self) -> None: @@ -66,7 +66,7 @@ def check_basis_functions(self): # spectrum. RGB = np.full(3, 1.0) sd = RGB_to_sd_Mallett2019(RGB, self._basis) - self.assertLess(np.var(sd.values), 1e-5) + assert np.var(sd.values) < 1e-5 # Check if the primaries or their combination exceeds the [0, 1] range. lower = np.zeros_like(sd.values) - 1e-12 @@ -89,21 +89,19 @@ def check_basis_functions(self): error = delta_E_CIE1976(Lab, recovered_Lab) if error > 4 * JND_CIE1976 / 100: # pragma: no cover - self.fail(f'Delta E for "{name}" is {error}!') + pytest.fail(f'Delta E for "{name}" is {error}!') -class TestSpectralPrimaryDecompositionMallett2019( - unittest.TestCase, TestMixinMallett2019 -): +class TestSpectralPrimaryDecompositionMallett2019(MixinTestMallett2019): """ Define :func:`colour.recovery.mallett2019.\ spectral_primary_decomposition_Mallett2019` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" - TestMixinMallett2019.__init__(self) + MixinTestMallett2019.__init__(self) self._RGB_colourspace = RGB_COLOURSPACE_PAL_SECAM @@ -120,16 +118,16 @@ def test_spectral_primary_decomposition_Mallett2019(self): self.check_basis_functions() -class TestRGB_to_sd_Mallett2019(unittest.TestCase, TestMixinMallett2019): +class TestRGB_to_sd_Mallett2019(MixinTestMallett2019): """ Define :func:`colour.recovery.mallett2019.RGB_to_sd_Mallett2019` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" - TestMixinMallett2019.__init__(self) + MixinTestMallett2019.__init__(self) self._RGB_colourspace = RGB_COLOURSPACE_sRGB self._basis = MSDS_BASIS_FUNCTIONS_sRGB_MALLETT2019 @@ -141,7 +139,3 @@ def test_RGB_to_sd_Mallett2019(self): """ self.check_basis_functions() - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/recovery/tests/test_meng2015.py b/colour/recovery/tests/test_meng2015.py index ad6937f53..9cc59a4af 100644 --- a/colour/recovery/tests/test_meng2015.py +++ b/colour/recovery/tests/test_meng2015.py @@ -1,9 +1,9 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.recovery.meng2015` module.""" -import unittest import numpy as np +import pytest from colour.colorimetry import ( MSDS_CMFS, @@ -29,13 +29,13 @@ ] -class TestXYZ_to_sd_Meng2015(unittest.TestCase): +class TestXYZ_to_sd_Meng2015: """ Define :func:`colour.recovery.meng2015.XYZ_to_sd_Meng2015` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._cmfs = reshape_msds( @@ -108,7 +108,7 @@ def test_raise_exception_XYZ_to_sd_Meng2015(self): definition raised exception. """ - self.assertRaises( + pytest.raises( RuntimeError, XYZ_to_sd_Meng2015, np.array([0.0, 0.0, 1.0]), @@ -142,7 +142,3 @@ def test_domain_range_scale_XYZ_to_sd_Meng2015(self): XYZ_o * factor_b, atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/recovery/tests/test_otsu2018.py b/colour/recovery/tests/test_otsu2018.py index 6e7d77c44..a4573634a 100644 --- a/colour/recovery/tests/test_otsu2018.py +++ b/colour/recovery/tests/test_otsu2018.py @@ -4,9 +4,9 @@ import os import shutil import tempfile -import unittest import numpy as np +import pytest from colour.characterisation import SDS_COLOURCHECKERS from colour.colorimetry import ( @@ -49,13 +49,13 @@ ] -class TestDataset_Otsu2018(unittest.TestCase): +class TestDataset_Otsu2018: """ Define :class:`colour.recovery.otsu2018.Dataset_Otsu2018` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._dataset = DATASET_REFERENCE_OTSU2018 @@ -66,7 +66,7 @@ def setUp(self): self._path = os.path.join(self._temporary_directory, "Test_Otsu2018.npz") self._dataset.write(self._path) - def tearDown(self): + def teardown_method(self): """After tests actions.""" shutil.rmtree(self._temporary_directory) @@ -82,7 +82,7 @@ def test_required_attributes(self): ) for attribute in required_attributes: - self.assertIn(attribute, dir(Dataset_Otsu2018)) + assert attribute in dir(Dataset_Otsu2018) def test_required_methods(self): """Test the presence of required methods.""" @@ -97,12 +97,12 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(Dataset_Otsu2018)) + assert method in dir(Dataset_Otsu2018) def test_shape(self): """Test :attr:`colour.recovery.otsu2018.Dataset_Otsu2018.shape` property.""" - self.assertEqual(self._dataset.shape, SPECTRAL_SHAPE_OTSU2018) + assert self._dataset.shape == SPECTRAL_SHAPE_OTSU2018 def test_basis_functions(self): """ @@ -110,7 +110,7 @@ def test_basis_functions(self): property. """ - self.assertTupleEqual(self._dataset.basis_functions.shape, (8, 3, 36)) + assert self._dataset.basis_functions.shape == (8, 3, 36) def test_means(self): """ @@ -118,7 +118,7 @@ def test_means(self): property. """ - self.assertTupleEqual(self._dataset.means.shape, (8, 36)) + assert self._dataset.means.shape == (8, 36) def test_selector_array(self): """ @@ -126,19 +126,19 @@ def test_selector_array(self): property. """ - self.assertTupleEqual(self._dataset.selector_array.shape, (7, 4)) + assert self._dataset.selector_array.shape == (7, 4) def test__str__(self): """Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.__str__` method.""" - self.assertEqual(str(self._dataset), "Dataset_Otsu2018(8 basis functions)") + assert str(self._dataset) == "Dataset_Otsu2018(8 basis functions)" - self.assertEqual(str(Dataset_Otsu2018()), "Dataset_Otsu2018()") + assert str(Dataset_Otsu2018()) == "Dataset_Otsu2018()" def test_select(self): """Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.select` method.""" - self.assertEqual(self._dataset.select(self._xy), 6) + assert self._dataset.select(self._xy) == 6 def test_raise_exception_select(self): """ @@ -146,14 +146,14 @@ def test_raise_exception_select(self): raised exception. """ - self.assertRaises(ValueError, Dataset_Otsu2018().select, np.array([0, 0])) + pytest.raises(ValueError, Dataset_Otsu2018().select, np.array([0, 0])) def test_cluster(self): """Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.cluster` method.""" basis_functions, means = self._dataset.cluster(self._xy) - self.assertTupleEqual(basis_functions.shape, (3, 36)) - self.assertTupleEqual(means.shape, (36,)) + assert basis_functions.shape == (3, 36) + assert means.shape == (36,) def test_raise_exception_cluster(self): """ @@ -161,7 +161,7 @@ def test_raise_exception_cluster(self): raised exception. """ - self.assertRaises(ValueError, Dataset_Otsu2018().cluster, np.array([0, 0])) + pytest.raises(ValueError, Dataset_Otsu2018().cluster, np.array([0, 0])) def test_read(self): """Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.read` method.""" @@ -169,10 +169,10 @@ def test_read(self): dataset = Dataset_Otsu2018() dataset.read(self._path) - self.assertEqual(dataset.shape, SPECTRAL_SHAPE_OTSU2018) - self.assertTupleEqual(dataset.basis_functions.shape, (8, 3, 36)) - self.assertTupleEqual(dataset.means.shape, (8, 36)) - self.assertTupleEqual(dataset.selector_array.shape, (7, 4)) + assert dataset.shape == SPECTRAL_SHAPE_OTSU2018 + assert dataset.basis_functions.shape == (8, 3, 36) + assert dataset.means.shape == (8, 36) + assert dataset.selector_array.shape == (7, 4) def test_write(self): """Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.write` method.""" @@ -182,10 +182,10 @@ def test_write(self): dataset = Dataset_Otsu2018() dataset.read(self._path) - self.assertEqual(dataset.shape, SPECTRAL_SHAPE_OTSU2018) - self.assertTupleEqual(dataset.basis_functions.shape, (8, 3, 36)) - self.assertTupleEqual(dataset.means.shape, (8, 36)) - self.assertTupleEqual(dataset.selector_array.shape, (7, 4)) + assert dataset.shape == SPECTRAL_SHAPE_OTSU2018 + assert dataset.basis_functions.shape == (8, 3, 36) + assert dataset.means.shape == (8, 36) + assert dataset.selector_array.shape == (7, 4) def test_raise_exception_write(self): """ @@ -193,16 +193,16 @@ def test_raise_exception_write(self): raised exception. """ - self.assertRaises(ValueError, Dataset_Otsu2018().write, "") + pytest.raises(ValueError, Dataset_Otsu2018().write, "") -class TestXYZ_to_sd_Otsu2018(unittest.TestCase): +class TestXYZ_to_sd_Otsu2018: """ Define :func:`colour.recovery.otsu2018.XYZ_to_sd_Otsu2018` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._shape = SPECTRAL_SHAPE_OTSU2018 @@ -226,10 +226,10 @@ def test_XYZ_to_sd_Otsu2018(self): reshape_sd(sd, SPECTRAL_SHAPE_OTSU2018).values, recovered_sd.values, ) - self.assertLess(error, 0.02) + assert error < 0.02 delta_E = delta_E_CIE1976(Lab, recovered_Lab) - self.assertLess(delta_E, 1e-12) + assert delta_E < 1e-12 def test_raise_exception_XYZ_to_sd_Otsu2018(self): """ @@ -237,7 +237,7 @@ def test_raise_exception_XYZ_to_sd_Otsu2018(self): raised_exception. """ - self.assertRaises( + pytest.raises( ValueError, XYZ_to_sd_Otsu2018, np.array([0, 0, 0]), @@ -273,13 +273,13 @@ def test_domain_range_scale_XYZ_to_sd_Otsu2018(self): ) -class TestData_Otsu2018(unittest.TestCase): +class TestData_Otsu2018: """ Define :class:`colour.recovery.otsu2018.Data_Otsu2018` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._shape = SPECTRAL_SHAPE_OTSU2018 @@ -308,7 +308,7 @@ def test_required_attributes(self): ) for attribute in required_attributes: - self.assertIn(attribute, dir(Data_Otsu2018)) + assert attribute in dir(Data_Otsu2018) def test_required_methods(self): """Test the presence of required methods.""" @@ -325,7 +325,7 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(Data_Otsu2018)) + assert method in dir(Data_Otsu2018) def test_reflectances(self): """ @@ -333,12 +333,12 @@ def test_reflectances(self): property. """ - self.assertIs(self._data.reflectances, self._reflectances) + assert self._data.reflectances is self._reflectances def test_cmfs(self): """Test :attr:`colour.recovery.otsu2018.Data_Otsu2018.cmfs` property.""" - self.assertIs(self._data.cmfs, self._cmfs) + assert self._data.cmfs is self._cmfs def test_illuminant(self): """ @@ -346,7 +346,7 @@ def test_illuminant(self): property. """ - self.assertIs(self._data.illuminant, self._sd_D65) + assert self._data.illuminant is self._sd_D65 def test_basis_functions(self): """ @@ -356,32 +356,32 @@ def test_basis_functions(self): data = Data_Otsu2018(self._reflectances, self._cmfs, self._sd_D65) - self.assertIsNone(data.basis_functions) + assert data.basis_functions is None data.PCA() - self.assertTupleEqual(data.basis_functions.shape, (3, 36)) + assert data.basis_functions.shape == (3, 36) def test_mean(self): """Test :attr:`colour.recovery.otsu2018.Data_Otsu2018.mean` property.""" data = Data_Otsu2018(self._reflectances, self._cmfs, self._sd_D65) - self.assertIsNone(data.mean) + assert data.mean is None data.PCA() - self.assertTupleEqual(data.mean.shape, (36,)) + assert data.mean.shape == (36,) def test__str__(self): """Test :meth:`colour.recovery.otsu2018.Data_Otsu2018.__str__` method.""" - self.assertEqual(str(self._data), "Data_Otsu2018(24 Reflectances)") + assert str(self._data) == "Data_Otsu2018(24 Reflectances)" def test__len__(self): """Test :meth:`colour.recovery.otsu2018.Data_Otsu2018.__len__` method.""" - self.assertEqual(len(self._data), 24) + assert len(self._data) == 24 def test_origin(self): """Test :meth:`colour.recovery.otsu2018.Data_Otsu2018.origin` method.""" @@ -398,7 +398,7 @@ def test_raise_exception_origin(self): raised exception. """ - self.assertRaises( + pytest.raises( ValueError, Data_Otsu2018(None, self._cmfs, self._sd_D65).origin, 4, @@ -410,7 +410,7 @@ def test_partition(self): partition = self._data.partition(PartitionAxis(4, 1)) - self.assertEqual(len(partition), 2) + assert len(partition) == 2 def test_raise_exception_partition(self): """ @@ -418,7 +418,7 @@ def test_raise_exception_partition(self): raised exception. """ - self.assertRaises( + pytest.raises( ValueError, Data_Otsu2018(None, self._cmfs, self._sd_D65).partition, PartitionAxis(4, 1), @@ -668,7 +668,7 @@ def test_raise_exception_reconstruct(self): raised exception. """ - self.assertRaises( + pytest.raises( ValueError, Data_Otsu2018(None, self._cmfs, self._sd_D65).reconstruct, np.array([0, 0, 0]), @@ -694,19 +694,19 @@ def test_raise_exception_reconstruction_error(self): reconstruction_error` method raised exception. """ - self.assertRaises( + pytest.raises( ValueError, Data_Otsu2018(None, self._cmfs, self._sd_D65).reconstruction_error, ) -class TestNode_Otsu2018(unittest.TestCase): +class TestNode_Otsu2018: """ Define :class:`colour.recovery.otsu2018.Node_Otsu2018` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._shape = SPECTRAL_SHAPE_OTSU2018 @@ -739,7 +739,7 @@ def test_required_attributes(self): required_attributes = ("partition_axis", "row") for attribute in required_attributes: - self.assertIn(attribute, dir(Node_Otsu2018)) + assert attribute in dir(Node_Otsu2018) def test_required_methods(self): """Test the presence of required methods.""" @@ -753,7 +753,7 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(Node_Otsu2018)) + assert method in dir(Node_Otsu2018) def test_partition_axis(self): """ @@ -761,19 +761,16 @@ def test_partition_axis(self): property. """ - self.assertIs(self._node_a.partition_axis, self._partition_axis) + assert self._node_a.partition_axis is self._partition_axis def test_row(self): """Test :attr:`colour.recovery.otsu2018.Node_Otsu2018.row` property.""" - self.assertTupleEqual( - self._node_a.row, - ( - self._partition_axis.origin, - self._partition_axis.direction, - self._node_b, - self._node_c, - ), + assert self._node_a.row == ( + self._partition_axis.origin, + self._partition_axis.direction, + self._node_b, + self._node_c, ) def test_raise_exception_row(self): @@ -782,7 +779,7 @@ def test_raise_exception_row(self): raised exception. """ - self.assertRaises(ValueError, lambda: Node_Otsu2018().row) + pytest.raises(ValueError, lambda: Node_Otsu2018().row) def test_split(self): """Test :meth:`colour.recovery.otsu2018.Node_Otsu2018.split` method.""" @@ -792,7 +789,7 @@ def test_split(self): node_c = Node_Otsu2018(self._tree, data=self._data_a) node_a.split([node_b, node_c], PartitionAxis(12, 0)) - self.assertEqual(len(node_a.children), 2) + assert len(node_a.children) == 2 def test_minimise(self): """Test :meth:`colour.recovery.otsu2018.Node_Otsu2018.minimise` method.""" @@ -800,9 +797,8 @@ def test_minimise(self): node = Node_Otsu2018(data=self._data_a) partition, axis, partition_error = node.minimise(3) - self.assertTupleEqual( - (len(partition[0].data), len(partition[1].data)), (10, 14) - ) + assert (len(partition[0].data), len(partition[1].data)) == (10, 14) + np.testing.assert_allclose( axis.origin, 0.324111380117147, atol=TOLERANCE_ABSOLUTE_TESTS ) @@ -835,13 +831,13 @@ def test_branch_reconstruction_error(self): ) -class TestTree_Otsu2018(unittest.TestCase): +class TestTree_Otsu2018: """ Define :class:`colour.recovery.otsu2018.Tree_Otsu2018` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._shape = SPECTRAL_SHAPE_OTSU2018 @@ -861,7 +857,7 @@ def setUp(self): self._path = os.path.join(self._temporary_directory, "Test_Otsu2018.npz") - def tearDown(self): + def teardown_method(self): """After tests actions.""" shutil.rmtree(self._temporary_directory) @@ -872,7 +868,7 @@ def test_required_attributes(self): required_attributes = ("reflectances", "cmfs", "illuminant") for attribute in required_attributes: - self.assertIn(attribute, dir(Tree_Otsu2018)) + assert attribute in dir(Tree_Otsu2018) def test_required_methods(self): """Test the presence of required methods.""" @@ -880,7 +876,7 @@ def test_required_methods(self): required_methods = ("__init__", "__str__", "optimise", "to_dataset") for method in required_methods: - self.assertIn(method, dir(Tree_Otsu2018)) + assert method in dir(Tree_Otsu2018) def test_reflectances(self): """ @@ -901,7 +897,7 @@ def test_reflectances(self): def test_cmfs(self): """Test :attr:`colour.recovery.otsu2018.Tree_Otsu2018.cmfs` property.""" - self.assertIs(self._tree.cmfs, self._cmfs) + assert self._tree.cmfs is self._cmfs def test_illuminant(self): """ @@ -909,7 +905,7 @@ def test_illuminant(self): property. """ - self.assertIs(self._tree.illuminant, self._sd_D65) + assert self._tree.illuminant is self._sd_D65 def test_optimise(self): """Test :class:`colour.recovery.otsu2018.Tree_Otsu2018.optimise` method.""" @@ -937,10 +933,10 @@ def test_optimise(self): reshape_sd(sd, SPECTRAL_SHAPE_OTSU2018).values, recovered_sd.values, ) - self.assertLess(error, 0.075) + assert error < 0.075 delta_E = delta_E_CIE1976(Lab, recovered_Lab) - self.assertLess(delta_E, 1e-12) + assert delta_E < 1e-12 def test_to_dataset(self): """ @@ -951,7 +947,3 @@ def test_to_dataset(self): node_tree = Tree_Otsu2018(self._reflectances, self._cmfs, self._sd_D65) dataset = node_tree.to_dataset() dataset.write(self._path) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/recovery/tests/test_smits1999.py b/colour/recovery/tests/test_smits1999.py index 9d794cbcf..2ffa9cd3e 100644 --- a/colour/recovery/tests/test_smits1999.py +++ b/colour/recovery/tests/test_smits1999.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.recovery.smits1999` module.""" -import unittest import numpy as np @@ -23,7 +22,7 @@ ] -class TestRGB_to_sd_Smits1999(unittest.TestCase): +class TestRGB_to_sd_Smits1999: """ Define :func:`colour.recovery.smits1999.RGB_to_sd_Smits1999` definition unit tests methods. @@ -173,7 +172,3 @@ def test_domain_range_scale_RGB_to_sd_Smits1999(self): XYZ_o * factor_b, atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/temperature/tests/test_cie_d.py b/colour/temperature/tests/test_cie_d.py index 21684caff..d8ab2874e 100644 --- a/colour/temperature/tests/test_cie_d.py +++ b/colour/temperature/tests/test_cie_d.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.temperature.cie_d` module.""" -import unittest from itertools import product import numpy as np @@ -23,7 +22,7 @@ ] -class TestXy_to_CCT_CIE_D(unittest.TestCase): +class TestXy_to_CCT_CIE_D: """ Define :func:`colour.temperature.cie_d.xy_to_CCT_CIE_D` definition unit tests methods. @@ -92,7 +91,7 @@ def test_nan_xy_to_CCT_CIE_D(self): xy_to_CCT_CIE_D(cases) -class TestCCT_to_xy_CIE_D(unittest.TestCase): +class TestCCT_to_xy_CIE_D: """ Define :func:`colour.temperature.cie_d.CCT_to_xy_CIE_D` definition unit tests methods. @@ -150,7 +149,3 @@ def test_nan_CCT_to_xy_CIE_D(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=2)))) CCT_to_xy_CIE_D(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/temperature/tests/test_hernandez1999.py b/colour/temperature/tests/test_hernandez1999.py index 385483fd8..4cda132c3 100644 --- a/colour/temperature/tests/test_hernandez1999.py +++ b/colour/temperature/tests/test_hernandez1999.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.temperature.hernandez1999` module.""" -import unittest from itertools import product import numpy as np @@ -23,7 +22,7 @@ ] -class Testxy_to_CCT_Hernandez1999(unittest.TestCase): +class Testxy_to_CCT_Hernandez1999: """ Define :func:`colour.temperature.hernandez1999.xy_to_CCT_Hernandez1999` definition unit tests methods. @@ -86,7 +85,7 @@ def test_nan_xy_to_CCT_Hernandez1999(self): xy_to_CCT_Hernandez1999(cases) -class TestCCT_to_xy_Hernandez1999(unittest.TestCase): +class TestCCT_to_xy_Hernandez1999: """ Define :func:`colour.temperature.hernandez1999.CCT_to_xy_Hernandez1999` definition unit tests methods. @@ -147,7 +146,3 @@ def test_nan_CCT_to_xy_Hernandez1999(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=2)))) CCT_to_xy_Hernandez1999(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/temperature/tests/test_kang2002.py b/colour/temperature/tests/test_kang2002.py index a32eee8fd..35b72c2bc 100644 --- a/colour/temperature/tests/test_kang2002.py +++ b/colour/temperature/tests/test_kang2002.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.temperature.kang2002` module.""" -import unittest from itertools import product import numpy as np @@ -23,7 +22,7 @@ ] -class TestXy_to_CCT_Kang2002(unittest.TestCase): +class TestXy_to_CCT_Kang2002: """ Define :func:`colour.temperature.kang2002.xy_to_CCT_Kang2002` definition unit tests methods. @@ -95,7 +94,7 @@ def test_nan_xy_to_CCT_Kang2002(self): xy_to_CCT_Kang2002(cases) -class TestCCT_to_xy_Kang2002(unittest.TestCase): +class TestCCT_to_xy_Kang2002: """ Define :func:`colour.temperature.kang2002.CCT_to_xy_Kang2002` definition unit tests methods. @@ -156,7 +155,3 @@ def test_nan_CCT_to_xy_Kang2002(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=2)))) CCT_to_xy_Kang2002(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/temperature/tests/test_krystek1985.py b/colour/temperature/tests/test_krystek1985.py index 897197f42..47a171033 100644 --- a/colour/temperature/tests/test_krystek1985.py +++ b/colour/temperature/tests/test_krystek1985.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.temperature.krystek1985` module.""" -import unittest from itertools import product import numpy as np @@ -22,7 +21,7 @@ ] -class TestUv_to_CCT_Krystek1985(unittest.TestCase): +class TestUv_to_CCT_Krystek1985: """ Define :func:`colour.temperature.krystek1985.uv_to_CCT_Krystek1985` definition unit tests methods. @@ -94,7 +93,7 @@ def test_nan_uv_to_CCT_Krystek1985(self): uv_to_CCT_Krystek1985(cases) -class TestCCT_to_uv_Krystek1985(unittest.TestCase): +class TestCCT_to_uv_Krystek1985: """ Define :func:`colour.temperature.krystek1985.CCT_to_uv_Krystek1985` definition unit tests methods. @@ -154,7 +153,3 @@ def test_nan_CCT_to_uv_Krystek1985(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] CCT_to_uv_Krystek1985(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/temperature/tests/test_mccamy1992.py b/colour/temperature/tests/test_mccamy1992.py index 74e1d272e..2ce51a532 100644 --- a/colour/temperature/tests/test_mccamy1992.py +++ b/colour/temperature/tests/test_mccamy1992.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.temperature.mccamy1992` module.""" -import unittest from itertools import product import numpy as np @@ -23,7 +22,7 @@ ] -class Testxy_to_CCT_McCamy1992(unittest.TestCase): +class Testxy_to_CCT_McCamy1992: """ Define :func:`colour.temperature.mccamy1992.xy_to_CCT_McCamy1992` definition unit tests methods. @@ -86,7 +85,7 @@ def test_nan_xy_to_CCT_McCamy1992(self): xy_to_CCT_McCamy1992(cases) -class TestCCT_to_xy_McCamy1992(unittest.TestCase): +class TestCCT_to_xy_McCamy1992: """ Define :func:`colour.temperature.mccamy1992.CCT_to_xy_McCamy1992` definition unit tests methods. @@ -147,7 +146,3 @@ def test_nan_CCT_to_xy_McCamy1992(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=2)))) CCT_to_xy_McCamy1992(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/temperature/tests/test_ohno2013.py b/colour/temperature/tests/test_ohno2013.py index bc951166a..2ef875597 100644 --- a/colour/temperature/tests/test_ohno2013.py +++ b/colour/temperature/tests/test_ohno2013.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.temperature.ohno2013` module.""" -import unittest from itertools import product import numpy as np @@ -35,7 +34,7 @@ ] -class TestPlanckianTable(unittest.TestCase): +class TestPlanckianTable: """ Define :func:`colour.temperature.ohno2013.planckian_table` definition unit tests methods. @@ -82,7 +81,7 @@ def test_planckian_table(self): ) -class TestUv_to_CCT_Ohno2013(unittest.TestCase): +class TestUv_to_CCT_Ohno2013: """ Define :func:`colour.temperature.ohno2013.uv_to_CCT_Ohno2013` definition unit tests methods. @@ -154,7 +153,7 @@ def test_nan_uv_to_CCT_Ohno2013(self): uv_to_CCT_Ohno2013(cases) -class TestCCT_to_uv_Ohno2013(unittest.TestCase): +class TestCCT_to_uv_Ohno2013: """ Define :func:`colour.temperature.ohno2013.CCT_to_uv_Ohno2013` definition unit tests methods. @@ -217,7 +216,7 @@ def test_nan_CCT_to_uv_Ohno2013(self): CCT_to_uv_Ohno2013(cases) -class Test_XYZ_to_CCT_Ohno2013(unittest.TestCase): +class Test_XYZ_to_CCT_Ohno2013: """ Define :func:`colour.temperature.ohno2013.XYZ_to_CCT_Ohno2013` definition unit tests methods. @@ -267,7 +266,7 @@ def test_nan_XYZ_to_CCT_Ohno2013(self): XYZ_to_CCT_Ohno2013(cases) -class Test_CCT_to_XYZ_Ohno2013(unittest.TestCase): +class Test_CCT_to_XYZ_Ohno2013: """ Define :func:`colour.temperature.ohno2013.CCT_to_XYZ_Ohno2013` definition unit tests methods. @@ -315,7 +314,3 @@ def test_nan_CCT_to_uv_Ohno2013(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=2)))) CCT_to_uv_Ohno2013(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/temperature/tests/test_planck1900.py b/colour/temperature/tests/test_planck1900.py index 0739e7a60..05a46fbb4 100644 --- a/colour/temperature/tests/test_planck1900.py +++ b/colour/temperature/tests/test_planck1900.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.temperature.planck1900` module.""" -import unittest from itertools import product import numpy as np @@ -23,7 +22,7 @@ ] -class TestUv_to_CCT_Planck1900(unittest.TestCase): +class TestUv_to_CCT_Planck1900: """ Define :func:`colour.temperature.planck1900.uv_to_CCT_Planck1900` definition unit tests methods. @@ -95,7 +94,7 @@ def test_nan_uv_to_CCT_Planck1900(self): uv_to_CCT_Planck1900(cases) -class TestCCT_to_uv_Planck1900(unittest.TestCase): +class TestCCT_to_uv_Planck1900: """ Define :func:`colour.temperature.planck1900.CCT_to_uv_Planck1900` definition unit tests methods. @@ -156,7 +155,3 @@ def test_nan_CCT_to_uv_Planck1900(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=2)))) CCT_to_uv_Planck1900(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/temperature/tests/test_robertson1968.py b/colour/temperature/tests/test_robertson1968.py index 2d9e99ab0..97cefa533 100644 --- a/colour/temperature/tests/test_robertson1968.py +++ b/colour/temperature/tests/test_robertson1968.py @@ -3,7 +3,6 @@ from __future__ import annotations -import unittest from itertools import product import numpy as np @@ -135,7 +134,7 @@ } -class TestMired_to_CCT(unittest.TestCase): +class TestMired_to_CCT: """ Define :func:`colour.temperature.robertson1968.mired_to_CCT` definition unit tests methods. @@ -194,7 +193,7 @@ def test_nan_mired_to_CCT(self): mired_to_CCT(cases) -class TestCCT_to_mired(unittest.TestCase): +class TestCCT_to_mired: """ Define :func:`colour.temperature.robertson1968.CCT_to_mired` definition unit tests methods. @@ -253,7 +252,7 @@ def test_nan_CCT_to_mired(self): CCT_to_mired(cases) -class TestUv_to_CCT_Robertson1968(unittest.TestCase): +class TestUv_to_CCT_Robertson1968: """ Define :func:`colour.temperature.robertson1968.uv_to_CCT_Robertson1968` definition unit tests methods. @@ -305,7 +304,7 @@ def test_nan_uv_to_CCT_Robertson1968(self): uv_to_CCT_Robertson1968(cases) -class TestCCT_to_uv_Robertson1968(unittest.TestCase): +class TestCCT_to_uv_Robertson1968: """ Define :func:`colour.temperature.robertson1968.CCT_to_uv_Robertson1968` definition unit tests methods. @@ -359,7 +358,3 @@ def test_nan_CCT_to_uv_Robertson1968(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=2)))) CCT_to_uv_Robertson1968(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/utilities/tests/test_array.py b/colour/utilities/tests/test_array.py index 5e57d567c..717e2f6c3 100644 --- a/colour/utilities/tests/test_array.py +++ b/colour/utilities/tests/test_array.py @@ -6,6 +6,7 @@ from dataclasses import dataclass, field, fields import numpy as np +import pytest from colour.constants import ( DTYPE_FLOAT_DEFAULT, @@ -146,7 +147,7 @@ def test_required_attributes(self): required_attributes = ("fields",) for method in required_attributes: - self.assertIn(method, dir(MixinDataclassFields)) + assert method in dir(MixinDataclassFields) def test_fields(self): """ @@ -154,10 +155,7 @@ def test_fields(self): method. """ - self.assertTupleEqual( - self._data.fields, - fields(self._data), - ) + assert self._data.fields == fields(self._data) class TestMixinDataclassIterable(unittest.TestCase): @@ -187,7 +185,7 @@ def test_required_attributes(self): ) for method in required_attributes: - self.assertIn(method, dir(MixinDataclassIterable)) + assert method in dir(MixinDataclassIterable) def test_required_methods(self): """Test the presence of required methods.""" @@ -195,7 +193,7 @@ def test_required_methods(self): required_methods = ("__iter__",) for method in required_methods: - self.assertIn(method, dir(MixinDataclassIterable)) + assert method in dir(MixinDataclassIterable) def test__iter__(self): """ @@ -203,9 +201,8 @@ def test__iter__(self): method. """ - self.assertDictEqual( - {key: value for key, value in self._data}, # noqa: C416 - {"a": "Foo", "b": "Bar", "c": "Baz"}, + assert {key: value for key, value in self._data} == ( # noqa: C416 + {"a": "Foo", "b": "Bar", "c": "Baz"} ) def test_keys(self): @@ -214,10 +211,7 @@ def test_keys(self): method. """ - self.assertTupleEqual( - tuple(self._data.keys), - ("a", "b", "c"), - ) + assert tuple(self._data.keys) == ("a", "b", "c") def test_values(self): """ @@ -225,10 +219,7 @@ def test_values(self): method. """ - self.assertTupleEqual( - tuple(self._data.values), - ("Foo", "Bar", "Baz"), - ) + assert tuple(self._data.values) == ("Foo", "Bar", "Baz") def test_items(self): """ @@ -236,10 +227,7 @@ def test_items(self): method. """ - self.assertTupleEqual( - tuple(self._data.items), - (("a", "Foo"), ("b", "Bar"), ("c", "Baz")), - ) + assert tuple(self._data.items) == (("a", "Foo"), ("b", "Bar"), ("c", "Baz")) class TestMixinDataclassArray(unittest.TestCase): @@ -282,7 +270,7 @@ def test_required_methods(self): required_methods = ("__array__",) for method in required_methods: - self.assertIn(method, dir(MixinDataclassArray)) + assert method in dir(MixinDataclassArray) def test__array__(self): """ @@ -292,10 +280,7 @@ def test__array__(self): np.testing.assert_array_equal(np.array(self._data), self._array) - self.assertEqual( - np.array(self._data, dtype=DTYPE_INT_DEFAULT).dtype, - DTYPE_INT_DEFAULT, - ) + assert np.array(self._data, dtype=DTYPE_INT_DEFAULT).dtype == DTYPE_INT_DEFAULT class TestMixinDataclassArithmetic(unittest.TestCase): @@ -351,7 +336,7 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(MixinDataclassArithmetic)) + assert method in dir(MixinDataclassArithmetic) def test_arithmetical_operation(self): """ @@ -468,19 +453,19 @@ def test_arithmetical_operation(self): data = self._factory(1, 2, 3) data += 1 - self.assertEqual(data.a, 2) + assert data.a == 2 data -= 1 - self.assertEqual(data.a, 1) + assert data.a == 1 data *= 2 - self.assertEqual(data.a, 2) + assert data.a == 2 data /= 2 - self.assertEqual(data.a, 1) + assert data.a == 1 data **= 0.5 - self.assertEqual(data.a, 1) + assert data.a == 1 class TestAsArray(unittest.TestCase): @@ -494,13 +479,9 @@ def test_as_array(self): np.testing.assert_equal(as_array([1, 2, 3]), np.array([1, 2, 3])) - self.assertEqual( - as_array([1, 2, 3], DTYPE_FLOAT_DEFAULT).dtype, DTYPE_FLOAT_DEFAULT - ) + assert as_array([1, 2, 3], DTYPE_FLOAT_DEFAULT).dtype == DTYPE_FLOAT_DEFAULT - self.assertEqual( - as_array([1, 2, 3], DTYPE_INT_DEFAULT).dtype, DTYPE_INT_DEFAULT - ) + assert as_array([1, 2, 3], DTYPE_INT_DEFAULT).dtype == DTYPE_INT_DEFAULT np.testing.assert_equal( as_array(dict(zip("abc", [1, 2, 3])).values()), np.array([1, 2, 3]) @@ -516,19 +497,19 @@ class TestAsInt(unittest.TestCase): def test_as_int(self): """Test :func:`colour.utilities.array.as_int` definition.""" - self.assertEqual(as_int(1), 1) + assert as_int(1) == 1 - self.assertEqual(as_int(np.array([1])).ndim, 1) + assert as_int(np.array([1])).ndim == 1 - self.assertEqual(as_int(np.array([[1]])).ndim, 2) + assert as_int(np.array([[1]])).ndim == 2 np.testing.assert_array_equal( as_int(np.array([1.0, 2.0, 3.0])), np.array([1, 2, 3]) ) - self.assertEqual(as_int(np.array([1.0, 2.0, 3.0])).dtype, DTYPE_INT_DEFAULT) + assert as_int(np.array([1.0, 2.0, 3.0])).dtype == DTYPE_INT_DEFAULT - self.assertIsInstance(as_int(1), DTYPE_INT_DEFAULT) + assert isinstance(as_int(1), DTYPE_INT_DEFAULT) class TestAsFloat(unittest.TestCase): @@ -540,11 +521,11 @@ class TestAsFloat(unittest.TestCase): def test_as_float(self): """Test :func:`colour.utilities.array.as_float` definition.""" - self.assertEqual(as_float(1), 1.0) + assert as_float(1) == 1.0 - self.assertEqual(as_float(np.array([1])).ndim, 1) + assert as_float(np.array([1])).ndim == 1 - self.assertEqual(as_float(np.array([[1]])).ndim, 2) + assert as_float(np.array([[1]])).ndim == 2 np.testing.assert_allclose( as_float(np.array([1, 2, 3])), @@ -552,9 +533,9 @@ def test_as_float(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - self.assertEqual(as_float(np.array([1, 2, 3])).dtype, DTYPE_FLOAT_DEFAULT) + assert as_float(np.array([1, 2, 3])).dtype == DTYPE_FLOAT_DEFAULT - self.assertIsInstance(as_float(1), DTYPE_FLOAT_DEFAULT) + assert isinstance(as_float(1), DTYPE_FLOAT_DEFAULT) class TestAsIntArray(unittest.TestCase): @@ -568,7 +549,7 @@ def test_as_int_array(self): np.testing.assert_equal(as_int_array([1.0, 2.0, 3.0]), np.array([1, 2, 3])) - self.assertEqual(as_int_array([1, 2, 3]).dtype, DTYPE_INT_DEFAULT) + assert as_int_array([1, 2, 3]).dtype == DTYPE_INT_DEFAULT class TestAsFloatArray(unittest.TestCase): @@ -582,7 +563,7 @@ def test_as_float_array(self): np.testing.assert_equal(as_float_array([1, 2, 3]), np.array([1, 2, 3])) - self.assertEqual(as_float_array([1, 2, 3]).dtype, DTYPE_FLOAT_DEFAULT) + assert as_float_array([1, 2, 3]).dtype == DTYPE_FLOAT_DEFAULT class TestAsIntScalar(unittest.TestCase): @@ -594,9 +575,9 @@ class TestAsIntScalar(unittest.TestCase): def test_as_int_scalar(self): """Test :func:`colour.utilities.array.as_int_scalar` definition.""" - self.assertEqual(as_int_scalar(1.0), 1) + assert as_int_scalar(1.0) == 1 - self.assertEqual(as_int_scalar(1.0).dtype, DTYPE_INT_DEFAULT) + assert as_int_scalar(1.0).dtype == DTYPE_INT_DEFAULT class TestAsFloatScalar(unittest.TestCase): @@ -608,9 +589,9 @@ class TestAsFloatScalar(unittest.TestCase): def test_as_float_scalar(self): """Test :func:`colour.utilities.array.as_float_scalar` definition.""" - self.assertEqual(as_float_scalar(1), 1.0) + assert as_float_scalar(1) == 1.0 - self.assertEqual(as_float_scalar(1).dtype, DTYPE_FLOAT_DEFAULT) + assert as_float_scalar(1).dtype == DTYPE_FLOAT_DEFAULT class TestSetDefaultIntegerDtype(unittest.TestCase): @@ -624,15 +605,15 @@ def test_set_default_int_dtype(self): Test :func:`colour.utilities.array.set_default_int_dtype` definition. """ - self.assertEqual(as_int_array(np.ones(3)).dtype, np.int64) + assert as_int_array(np.ones(3)).dtype == np.int64 set_default_int_dtype(np.int32) - self.assertEqual(as_int_array(np.ones(3)).dtype, np.int32) + assert as_int_array(np.ones(3)).dtype == np.int32 set_default_int_dtype(np.int64) - self.assertEqual(as_int_array(np.ones(3)).dtype, np.int64) + assert as_int_array(np.ones(3)).dtype == np.int64 def tearDown(self): """After tests actions.""" @@ -653,15 +634,15 @@ def test_set_default_float_dtype(self): """ try: - self.assertEqual(as_float_array(np.ones(3)).dtype, np.float64) + assert as_float_array(np.ones(3)).dtype == np.float64 set_default_float_dtype(np.float16) - self.assertEqual(as_float_array(np.ones(3)).dtype, np.float16) + assert as_float_array(np.ones(3)).dtype == np.float16 set_default_float_dtype(np.float64) - self.assertEqual(as_float_array(np.ones(3)).dtype, np.float64) + assert as_float_array(np.ones(3)).dtype == np.float64 finally: set_default_float_dtype(np.float64) @@ -766,7 +747,7 @@ def dtype_getter(x): return x.dtype - self.assertEqual(dtype_getter(convert(a, source, target)), dtype) + assert dtype_getter(convert(a, source, target)) == dtype finally: set_default_float_dtype(np.float64) @@ -784,13 +765,13 @@ def test_get_domain_range_scale(self): """ with domain_range_scale("Reference"): - self.assertEqual(get_domain_range_scale(), "reference") + assert get_domain_range_scale() == "reference" with domain_range_scale("1"): - self.assertEqual(get_domain_range_scale(), "1") + assert get_domain_range_scale() == "1" with domain_range_scale("100"): - self.assertEqual(get_domain_range_scale(), "100") + assert get_domain_range_scale() == "100" class TestSetDomainRangeScale(unittest.TestCase): @@ -807,17 +788,18 @@ def test_set_domain_range_scale(self): with domain_range_scale("Reference"): set_domain_range_scale("1") - self.assertEqual(get_domain_range_scale(), "1") + assert get_domain_range_scale() == "1" with domain_range_scale("Reference"): set_domain_range_scale("100") - self.assertEqual(get_domain_range_scale(), "100") + assert get_domain_range_scale() == "100" with domain_range_scale("1"): set_domain_range_scale("Reference") - self.assertEqual(get_domain_range_scale(), "reference") + assert get_domain_range_scale() == "reference" - self.assertRaises(ValueError, lambda: set_domain_range_scale("Invalid")) + with pytest.raises(ValueError): + set_domain_range_scale("Invalid") class TestDomainRangeScale(unittest.TestCase): @@ -832,22 +814,22 @@ def test_domain_range_scale(self): definition. """ - self.assertEqual(get_domain_range_scale(), "reference") + assert get_domain_range_scale() == "reference" with domain_range_scale("Reference"): - self.assertEqual(get_domain_range_scale(), "reference") + assert get_domain_range_scale() == "reference" - self.assertEqual(get_domain_range_scale(), "reference") + assert get_domain_range_scale() == "reference" with domain_range_scale("1"): - self.assertEqual(get_domain_range_scale(), "1") + assert get_domain_range_scale() == "1" - self.assertEqual(get_domain_range_scale(), "reference") + assert get_domain_range_scale() == "reference" with domain_range_scale("100"): - self.assertEqual(get_domain_range_scale(), "100") + assert get_domain_range_scale() == "100" - self.assertEqual(get_domain_range_scale(), "reference") + assert get_domain_range_scale() == "reference" def fn_a(a): """Change the domain-range scale for unit testing.""" @@ -862,19 +844,19 @@ def fn_a(a): with domain_range_scale("1"): with domain_range_scale("100"): with domain_range_scale("Ignore"): - self.assertEqual(get_domain_range_scale(), "ignore") - self.assertEqual(fn_a(4), 8) + assert get_domain_range_scale() == "ignore" + assert fn_a(4) == 8 - self.assertEqual(get_domain_range_scale(), "100") - self.assertEqual(fn_a(40), 8) + assert get_domain_range_scale() == "100" + assert fn_a(40) == 8 - self.assertEqual(get_domain_range_scale(), "1") - self.assertEqual(fn_a(0.4), 0.08) + assert get_domain_range_scale() == "1" + assert fn_a(0.4) == 0.08 - self.assertEqual(get_domain_range_scale(), "reference") - self.assertEqual(fn_a(4), 8) + assert get_domain_range_scale() == "reference" + assert fn_a(4) == 8 - self.assertEqual(get_domain_range_scale(), "reference") + assert get_domain_range_scale() == "reference" @domain_range_scale("1") def fn_b(a): @@ -886,7 +868,7 @@ def fn_b(a): return from_range_100(b) - self.assertEqual(fn_b(10), 2.0) + assert fn_b(10) == 2.0 class TestToDomain1(unittest.TestCase): @@ -899,19 +881,19 @@ def test_to_domain_1(self): """Test :func:`colour.utilities.common.to_domain_1` definition.""" with domain_range_scale("Reference"): - self.assertEqual(to_domain_1(1), 1) + assert to_domain_1(1) == 1 with domain_range_scale("1"): - self.assertEqual(to_domain_1(1), 1) + assert to_domain_1(1) == 1 with domain_range_scale("100"): - self.assertEqual(to_domain_1(1), 0.01) + assert to_domain_1(1) == 0.01 with domain_range_scale("100"): - self.assertEqual(to_domain_1(1, np.pi), 1 / np.pi) + assert to_domain_1(1, np.pi) == 1 / np.pi with domain_range_scale("100"): - self.assertEqual(to_domain_1(1, dtype=np.float16).dtype, np.float16) + assert to_domain_1(1, dtype=np.float16).dtype == np.float16 class TestToDomain10(unittest.TestCase): @@ -924,19 +906,19 @@ def test_to_domain_10(self): """Test :func:`colour.utilities.common.to_domain_10` definition.""" with domain_range_scale("Reference"): - self.assertEqual(to_domain_10(1), 1) + assert to_domain_10(1) == 1 with domain_range_scale("1"): - self.assertEqual(to_domain_10(1), 10) + assert to_domain_10(1) == 10 with domain_range_scale("100"): - self.assertEqual(to_domain_10(1), 0.1) + assert to_domain_10(1) == 0.1 with domain_range_scale("100"): - self.assertEqual(to_domain_10(1, np.pi), 1 / np.pi) + assert to_domain_10(1, np.pi) == 1 / np.pi with domain_range_scale("100"): - self.assertEqual(to_domain_10(1, dtype=np.float16).dtype, np.float16) + assert to_domain_10(1, dtype=np.float16).dtype == np.float16 class TestToDomain100(unittest.TestCase): @@ -949,19 +931,19 @@ def test_to_domain_100(self): """Test :func:`colour.utilities.common.to_domain_100` definition.""" with domain_range_scale("Reference"): - self.assertEqual(to_domain_100(1), 1) + assert to_domain_100(1) == 1 with domain_range_scale("1"): - self.assertEqual(to_domain_100(1), 100) + assert to_domain_100(1) == 100 with domain_range_scale("100"): - self.assertEqual(to_domain_100(1), 1) + assert to_domain_100(1) == 1 with domain_range_scale("1"): - self.assertEqual(to_domain_100(1, np.pi), np.pi) + assert to_domain_100(1, np.pi) == np.pi with domain_range_scale("100"): - self.assertEqual(to_domain_100(1, dtype=np.float16).dtype, np.float16) + assert to_domain_100(1, dtype=np.float16).dtype == np.float16 class TestToDomainDegrees(unittest.TestCase): @@ -974,19 +956,19 @@ def test_to_domain_degrees(self): """Test :func:`colour.utilities.common.to_domain_degrees` definition.""" with domain_range_scale("Reference"): - self.assertEqual(to_domain_degrees(1), 1) + assert to_domain_degrees(1) == 1 with domain_range_scale("1"): - self.assertEqual(to_domain_degrees(1), 360) + assert to_domain_degrees(1) == 360 with domain_range_scale("100"): - self.assertEqual(to_domain_degrees(1), 3.6) + assert to_domain_degrees(1) == 3.6 with domain_range_scale("100"): - self.assertEqual(to_domain_degrees(1, np.pi), np.pi / 100) + assert to_domain_degrees(1, np.pi) == np.pi / 100 with domain_range_scale("100"): - self.assertEqual(to_domain_degrees(1, dtype=np.float16).dtype, np.float16) + assert to_domain_degrees(1, dtype=np.float16).dtype == np.float16 class TestToDomainInt(unittest.TestCase): @@ -999,19 +981,19 @@ def test_to_domain_int(self): """Test :func:`colour.utilities.common.to_domain_int` definition.""" with domain_range_scale("Reference"): - self.assertEqual(to_domain_int(1), 1) + assert to_domain_int(1) == 1 with domain_range_scale("1"): - self.assertEqual(to_domain_int(1), 255) + assert to_domain_int(1) == 255 with domain_range_scale("100"): - self.assertEqual(to_domain_int(1), 2.55) + assert to_domain_int(1) == 2.55 with domain_range_scale("100"): - self.assertEqual(to_domain_int(1, 10), 10.23) + assert to_domain_int(1, 10) == 10.23 with domain_range_scale("100"): - self.assertEqual(to_domain_int(1, dtype=np.float16).dtype, np.float16) + assert to_domain_int(1, dtype=np.float16).dtype == np.float16 class TestFromRange1(unittest.TestCase): @@ -1024,16 +1006,16 @@ def test_from_range_1(self): """Test :func:`colour.utilities.common.from_range_1` definition.""" with domain_range_scale("Reference"): - self.assertEqual(from_range_1(1), 1) + assert from_range_1(1) == 1 with domain_range_scale("1"): - self.assertEqual(from_range_1(1), 1) + assert from_range_1(1) == 1 with domain_range_scale("100"): - self.assertEqual(from_range_1(1), 100) + assert from_range_1(1) == 100 with domain_range_scale("100"): - self.assertEqual(from_range_1(1, np.pi), 1 * np.pi) + assert from_range_1(1, np.pi) == 1 * np.pi class TestFromRange10(unittest.TestCase): @@ -1046,16 +1028,16 @@ def test_from_range_10(self): """Test :func:`colour.utilities.common.from_range_10` definition.""" with domain_range_scale("Reference"): - self.assertEqual(from_range_10(1), 1) + assert from_range_10(1) == 1 with domain_range_scale("1"): - self.assertEqual(from_range_10(1), 0.1) + assert from_range_10(1) == 0.1 with domain_range_scale("100"): - self.assertEqual(from_range_10(1), 10) + assert from_range_10(1) == 10 with domain_range_scale("100"): - self.assertEqual(from_range_10(1, np.pi), 1 * np.pi) + assert from_range_10(1, np.pi) == 1 * np.pi class TestFromRange100(unittest.TestCase): @@ -1068,16 +1050,16 @@ def test_from_range_100(self): """Test :func:`colour.utilities.common.from_range_100` definition.""" with domain_range_scale("Reference"): - self.assertEqual(from_range_100(1), 1) + assert from_range_100(1) == 1 with domain_range_scale("1"): - self.assertEqual(from_range_100(1), 0.01) + assert from_range_100(1) == 0.01 with domain_range_scale("100"): - self.assertEqual(from_range_100(1), 1) + assert from_range_100(1) == 1 with domain_range_scale("1"): - self.assertEqual(from_range_100(1, np.pi), 1 / np.pi) + assert from_range_100(1, np.pi) == 1 / np.pi class TestFromRangeDegrees(unittest.TestCase): @@ -1090,16 +1072,16 @@ def test_from_range_degrees(self): """Test :func:`colour.utilities.common.from_range_degrees` definition.""" with domain_range_scale("Reference"): - self.assertEqual(from_range_degrees(1), 1) + assert from_range_degrees(1) == 1 with domain_range_scale("1"): - self.assertEqual(from_range_degrees(1), 1 / 360) + assert from_range_degrees(1) == 1 / 360 with domain_range_scale("100"): - self.assertEqual(from_range_degrees(1), 1 / 3.6) + assert from_range_degrees(1) == 1 / 3.6 with domain_range_scale("100"): - self.assertEqual(from_range_degrees(1, np.pi), 1 / (np.pi / 100)) + assert from_range_degrees(1, np.pi) == 1 / (np.pi / 100) class TestFromRangeInt(unittest.TestCase): @@ -1112,19 +1094,19 @@ def test_from_range_int(self): """Test :func:`colour.utilities.common.from_range_int` definition.""" with domain_range_scale("Reference"): - self.assertEqual(from_range_int(1), 1) + assert from_range_int(1) == 1 with domain_range_scale("1"): - self.assertEqual(from_range_int(1), 1 / 255) + assert from_range_int(1) == 1 / 255 with domain_range_scale("100"): - self.assertEqual(from_range_int(1), 1 / 2.55) + assert from_range_int(1) == 1 / 2.55 with domain_range_scale("100"): - self.assertEqual(from_range_int(1, 10), 1 / (1023 / 100)) + assert from_range_int(1, 10) == 1 / (1023 / 100) with domain_range_scale("100"): - self.assertEqual(from_range_int(1, dtype=np.float16).dtype, np.float16) + assert from_range_int(1, dtype=np.float16).dtype == np.float16 class TestIsNdarrayCopyEnabled(unittest.TestCase): @@ -1139,10 +1121,10 @@ def test_is_ndarray_copy_enabled(self): """ with ndarray_copy_enable(True): - self.assertTrue(is_ndarray_copy_enabled()) + assert is_ndarray_copy_enabled() with ndarray_copy_enable(False): - self.assertFalse(is_ndarray_copy_enabled()) + assert not is_ndarray_copy_enabled() class TestSetNdarrayCopyEnabled(unittest.TestCase): @@ -1158,11 +1140,11 @@ def test_set_ndarray_copy_enable(self): with ndarray_copy_enable(is_ndarray_copy_enabled()): set_ndarray_copy_enable(True) - self.assertTrue(is_ndarray_copy_enabled()) + assert is_ndarray_copy_enabled() with ndarray_copy_enable(is_ndarray_copy_enabled()): set_ndarray_copy_enable(False) - self.assertFalse(is_ndarray_copy_enabled()) + assert not is_ndarray_copy_enabled() class TestNdarrayCopyEnable(unittest.TestCase): @@ -1177,16 +1159,16 @@ def test_ndarray_copy_enable(self): """ with ndarray_copy_enable(True): - self.assertTrue(is_ndarray_copy_enabled()) + assert is_ndarray_copy_enabled() with ndarray_copy_enable(False): - self.assertFalse(is_ndarray_copy_enabled()) + assert not is_ndarray_copy_enabled() @ndarray_copy_enable(True) def fn_a(): """:func:`ndarray_copy_enable` unit tests :func:`fn_a` definition.""" - self.assertTrue(is_ndarray_copy_enabled()) + assert is_ndarray_copy_enabled() fn_a() @@ -1194,7 +1176,7 @@ def fn_a(): def fn_b(): """:func:`ndarray_copy_enable` unit tests :func:`fn_b` definition.""" - self.assertFalse(is_ndarray_copy_enabled()) + assert not is_ndarray_copy_enabled() fn_b() @@ -1210,10 +1192,10 @@ def test_ndarray_copy(self): a = np.linspace(0, 1, 10) with ndarray_copy_enable(True): - self.assertNotEqual(id(ndarray_copy(a)), id(a)) + assert id(ndarray_copy(a)) != id(a) with ndarray_copy_enable(False): - self.assertEqual(id(ndarray_copy(a)), id(a)) + assert id(ndarray_copy(a)) == id(a) class TestClosestIndexes(unittest.TestCase): @@ -1236,11 +1218,11 @@ def test_closest_indexes(self): ] ) - self.assertEqual(closest_indexes(a, 63.05), 3) + assert closest_indexes(a, 63.05) == 3 - self.assertEqual(closest_indexes(a, 51.15), 4) + assert closest_indexes(a, 51.15) == 4 - self.assertEqual(closest_indexes(a, 24.90), 5) + assert closest_indexes(a, 24.90) == 5 np.testing.assert_array_equal( closest_indexes(a, np.array([63.05, 51.15, 24.90])), @@ -1268,11 +1250,11 @@ def test_closest(self): ] ) - self.assertEqual(closest(a, 63.05), 62.70988028) + assert closest(a, 63.05) == 62.70988028 - self.assertEqual(closest(a, 51.15), 46.84480573) + assert closest(a, 51.15) == 46.84480573 - self.assertEqual(closest(a, 24.90), 25.40026416) + assert closest(a, 24.90) == 25.40026416 np.testing.assert_allclose( closest(a, np.array([63.05, 51.15, 24.90])), @@ -1318,9 +1300,9 @@ class TestIsUniform(unittest.TestCase): def test_is_uniform(self): """Test :func:`colour.utilities.array.is_uniform` definition.""" - self.assertTrue(is_uniform(range(0, 10, 2))) + assert is_uniform(range(0, 10, 2)) - self.assertFalse(is_uniform([1, 2, 3, 4, 6])) + assert not is_uniform([1, 2, 3, 4, 6]) class TestInArray(unittest.TestCase): @@ -1332,25 +1314,19 @@ class TestInArray(unittest.TestCase): def test_in_array(self): """Test :func:`colour.utilities.array.in_array` definition.""" - self.assertTrue( - np.array_equal( - in_array(np.array([0.50, 0.60]), np.linspace(0, 10, 101)), - np.array([True, True]), - ) + assert np.array_equal( + in_array(np.array([0.50, 0.60]), np.linspace(0, 10, 101)), + np.array([True, True]), ) - self.assertFalse( - np.array_equal( - in_array(np.array([0.50, 0.61]), np.linspace(0, 10, 101)), - np.array([True, True]), - ) + assert not np.array_equal( + in_array(np.array([0.50, 0.61]), np.linspace(0, 10, 101)), + np.array([True, True]), ) - self.assertTrue( - np.array_equal( - in_array(np.array([[0.50], [0.60]]), np.linspace(0, 10, 101)), - np.array([[True], [True]]), - ) + assert np.array_equal( + in_array(np.array([[0.50], [0.60]]), np.linspace(0, 10, 101)), + np.array([[True], [True]]), ) def test_n_dimensional_in_array(self): @@ -1695,13 +1671,13 @@ class TestHasNanOnly(unittest.TestCase): def test_has_only_nan(self): """Test :func:`colour.utilities.array.has_only_nan` definition.""" - self.assertTrue(has_only_nan(None)) + assert has_only_nan(None) - self.assertTrue(has_only_nan([None, None])) + assert has_only_nan([None, None]) - self.assertFalse(has_only_nan([True, None])) + assert not has_only_nan([True, None]) - self.assertFalse(has_only_nan([0.1, np.nan, 0.3])) + assert not has_only_nan([0.1, np.nan, 0.3]) class TestNdarrayWrite(unittest.TestCase): @@ -1716,7 +1692,7 @@ def test_ndarray_write(self): a = np.linspace(0, 1, 10) a.setflags(write=False) - with self.assertRaises(ValueError): + with pytest.raises(ValueError): a += 1 with ndarray_write(a): @@ -1840,17 +1816,17 @@ def test_exceptions(self): a = as_float_array([[11, 12], [21, 22]]) # Bad shape - with self.assertRaises(ValueError): + with pytest.raises(ValueError): indexes = np.array([0]) index_along_last_axis(a, indexes) # Indexes out of range - with self.assertRaises(IndexError): + with pytest.raises(IndexError): indexes = np.array([123, 456]) index_along_last_axis(a, indexes) # Non-int indexes - with self.assertRaises(IndexError): + with pytest.raises(IndexError): indexes = np.array([0.0, 0.0]) index_along_last_axis(a, indexes) @@ -1864,21 +1840,8 @@ class TestFormatArrayAsRow(unittest.TestCase): def test_format_array_as_row(self): """Test :func:`colour.utilities.array.format_array_as_row` definition.""" - self.assertEqual( - format_array_as_row([1.25, 2.5, 3.75]), - "1.2500000 2.5000000 3.7500000", - ) - - self.assertEqual( - format_array_as_row([1.25, 2.5, 3.75], 3), - "1.250 2.500 3.750", - ) - - self.assertEqual( - format_array_as_row([1.25, 2.5, 3.75], 3, ", "), - "1.250, 2.500, 3.750", - ) + assert format_array_as_row([1.25, 2.5, 3.75]) == "1.2500000 2.5000000 3.7500000" + assert format_array_as_row([1.25, 2.5, 3.75], 3) == "1.250 2.500 3.750" -if __name__ == "__main__": - unittest.main() + assert format_array_as_row([1.25, 2.5, 3.75], 3, ", ") == "1.250, 2.500, 3.750" diff --git a/colour/utilities/tests/test_callback.py b/colour/utilities/tests/test_callback.py index 245f0ef37..6f9266d3b 100644 --- a/colour/utilities/tests/test_callback.py +++ b/colour/utilities/tests/test_callback.py @@ -3,8 +3,6 @@ from __future__ import annotations -import unittest - from colour.utilities import MixinCallback __author__ = "Colour Developers" @@ -19,13 +17,13 @@ ] -class TestMixinCallback(unittest.TestCase): +class TestMixinCallback: """ Define :class:`colour.utilities.callback.MixinCallback` class unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" class WithCallback(MixinCallback): @@ -58,7 +56,7 @@ def test_required_attributes(self): required_attributes = ("callbacks",) for attribute in required_attributes: - self.assertIn(attribute, dir(MixinCallback)) + assert attribute in dir(MixinCallback) def test_required_methods(self): """Test the presence of required methods.""" @@ -70,7 +68,7 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(MixinCallback)) + assert method in dir(MixinCallback) def test_register_callback(self): """ @@ -85,8 +83,8 @@ def test_register_callback(self): ) self._with_callback.attribute_a = "a" - self.assertEqual(self._with_callback.attribute_a, "A") - self.assertEqual(len(self._with_callback.callbacks), 1) + assert self._with_callback.attribute_a == "A" + assert len(self._with_callback.callbacks) == 1 def test_unregister_callback(self): """ @@ -101,12 +99,8 @@ def test_unregister_callback(self): self._on_attribute_a_changed, ) - self.assertEqual(len(self._with_callback.callbacks), 1) + assert len(self._with_callback.callbacks) == 1 self._with_callback.unregister_callback("attribute_a", "on_attribute_a_changed") - self.assertEqual(len(self._with_callback.callbacks), 0) + assert len(self._with_callback.callbacks) == 0 self._with_callback.attribute_a = "a" - self.assertEqual(self._with_callback.attribute_a, "a") - - -if __name__ == "__main__": - unittest.main() + assert self._with_callback.attribute_a == "a" diff --git a/colour/utilities/tests/test_common.py b/colour/utilities/tests/test_common.py index cdb8e0ef3..1cf53130d 100644 --- a/colour/utilities/tests/test_common.py +++ b/colour/utilities/tests/test_common.py @@ -5,10 +5,10 @@ import platform import unicodedata -import unittest from functools import partial import numpy as np +import pytest from colour.hints import Any, Real, Tuple from colour.utilities import ( @@ -65,7 +65,7 @@ ] -class TestIsCachingEnabled(unittest.TestCase): +class TestIsCachingEnabled: """ Define :func:`colour.utilities.common.is_caching_enabled` definition unit tests methods. @@ -75,13 +75,13 @@ def test_is_caching_enabled(self): """Test :func:`colour.utilities.common.is_caching_enabled` definition.""" with caching_enable(True): - self.assertTrue(is_caching_enabled()) + assert is_caching_enabled() with caching_enable(False): - self.assertFalse(is_caching_enabled()) + assert not is_caching_enabled() -class TestSetCachingEnabled(unittest.TestCase): +class TestSetCachingEnabled: """ Define :func:`colour.utilities.common.set_caching_enable` definition unit tests methods. @@ -92,14 +92,14 @@ def test_set_caching_enable(self): with caching_enable(is_caching_enabled()): set_caching_enable(True) - self.assertTrue(is_caching_enabled()) + assert is_caching_enabled() with caching_enable(is_caching_enabled()): set_caching_enable(False) - self.assertFalse(is_caching_enabled()) + assert not is_caching_enabled() -class TestCachingEnable(unittest.TestCase): +class TestCachingEnable: """ Define :func:`colour.utilities.common.caching_enable` definition unit tests methods. @@ -109,16 +109,16 @@ def test_caching_enable(self): """Test :func:`colour.utilities.common.caching_enable` definition.""" with caching_enable(True): - self.assertTrue(is_caching_enabled()) + assert is_caching_enabled() with caching_enable(False): - self.assertFalse(is_caching_enabled()) + assert not is_caching_enabled() @caching_enable(True) def fn_a(): """:func:`caching_enable` unit tests :func:`fn_a` definition.""" - self.assertTrue(is_caching_enabled()) + assert is_caching_enabled() fn_a() @@ -126,12 +126,12 @@ def fn_a(): def fn_b(): """:func:`caching_enable` unit tests :func:`fn_b` definition.""" - self.assertFalse(is_caching_enabled()) + assert not is_caching_enabled() fn_b() -class TestCacheRegistry(unittest.TestCase): +class TestCacheRegistry: """ Define :class:`colour.utilities.common.CacheRegistry` class unit tests methods. @@ -156,7 +156,7 @@ def test_required_attributes(self): required_attributes = ("registry",) for attribute in required_attributes: - self.assertIn(attribute, dir(CacheRegistry)) + assert attribute in dir(CacheRegistry) def test_required_methods(self): """Test the presence of required methods.""" @@ -171,16 +171,13 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(CacheRegistry)) + assert method in dir(CacheRegistry) def test__str__(self): """Test :class:`colour.utilities.common.CacheRegistry.__str__` method.""" cache_registry = self._default_test_cache_registry() - self.assertEqual( - str(cache_registry), - "{'Cache A': '1 item(s)', 'Cache B': '2 item(s)'}", - ) + assert str(cache_registry) == "{'Cache A': '1 item(s)', 'Cache B': '2 item(s)'}" def test_register_cache(self): """ @@ -190,11 +187,9 @@ def test_register_cache(self): cache_registry = CacheRegistry() cache_a = cache_registry.register_cache("Cache A") - self.assertDictEqual(cache_registry.registry, {"Cache A": cache_a}) + assert cache_registry.registry == {"Cache A": cache_a} cache_b = cache_registry.register_cache("Cache B") - self.assertDictEqual( - cache_registry.registry, {"Cache A": cache_a, "Cache B": cache_b} - ) + assert cache_registry.registry == {"Cache A": cache_a, "Cache B": cache_b} def test_unregister_cache(self): """ @@ -204,8 +199,8 @@ def test_unregister_cache(self): cache_registry = self._default_test_cache_registry() cache_registry.unregister_cache("Cache A") - self.assertNotIn("Cache A", cache_registry.registry) - self.assertIn("Cache B", cache_registry.registry) + assert "Cache A" not in cache_registry.registry + assert "Cache B" in cache_registry.registry def test_clear_cache(self): """ @@ -215,10 +210,10 @@ def test_clear_cache(self): cache_registry = self._default_test_cache_registry() cache_registry.clear_cache("Cache A") - self.assertDictEqual( - cache_registry.registry, - {"Cache A": {}, "Cache B": {"John": "Doe", "Luke": "Skywalker"}}, - ) + assert cache_registry.registry == { + "Cache A": {}, + "Cache B": {"John": "Doe", "Luke": "Skywalker"}, + } def test_clear_all_caches(self): """ @@ -228,10 +223,10 @@ def test_clear_all_caches(self): cache_registry = self._default_test_cache_registry() cache_registry.clear_all_caches() - self.assertDictEqual(cache_registry.registry, {"Cache A": {}, "Cache B": {}}) + assert cache_registry.registry == {"Cache A": {}, "Cache B": {}} -class TestAttest(unittest.TestCase): +class TestAttest: """ Define :func:`colour.utilities.common.attest` definition unit tests methods. @@ -240,12 +235,12 @@ class TestAttest(unittest.TestCase): def test_attest(self): """Test :func:`colour.utilities.common.attest` definition.""" - self.assertIsNone(attest(True, "")) + assert attest(True, "") is None - self.assertRaises(AssertionError, attest, False) + pytest.raises(AssertionError, attest, False) -class TestBatch(unittest.TestCase): +class TestBatch: """ Define :func:`colour.utilities.common.batch` definition unit tests methods. @@ -254,20 +249,27 @@ class TestBatch(unittest.TestCase): def test_batch(self): """Test :func:`colour.utilities.common.batch` definition.""" - self.assertListEqual( - list(batch(tuple(range(10)), 3)), - [(0, 1, 2), (3, 4, 5), (6, 7, 8), (9,)], - ) - - self.assertListEqual( - list(batch(tuple(range(10)), 5)), - [(0, 1, 2, 3, 4), (5, 6, 7, 8, 9)], - ) - - self.assertListEqual( - list(batch(tuple(range(10)), 1)), - [(0,), (1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,)], - ) + assert list(batch(tuple(range(10)), 3)) == [ + (0, 1, 2), + (3, 4, 5), + (6, 7, 8), + (9,), + ] + + assert list(batch(tuple(range(10)), 5)) == [(0, 1, 2, 3, 4), (5, 6, 7, 8, 9)] + + assert list(batch(tuple(range(10)), 1)) == [ + (0,), + (1,), + (2,), + (3,), + (4,), + (5,), + (6,), + (7,), + (8,), + (9,), + ] def _add(a: Real, b: Real): @@ -295,7 +297,7 @@ def _add(a: Real, b: Real): return a + b # pragma: no cover -class TestMultiprocessingPool(unittest.TestCase): +class TestMultiprocessingPool: """ Define :func:`colour.utilities.common.multiprocessing_pool` definition unit tests methods. @@ -305,13 +307,21 @@ def test_multiprocessing_pool(self): """Test :func:`colour.utilities.common.multiprocessing_pool` definition.""" with multiprocessing_pool() as pool: - self.assertListEqual( - pool.map(partial(_add, b=2), range(10)), - [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], - ) - - -class TestAsBool(unittest.TestCase): + assert pool.map(partial(_add, b=2), range(10)) == [ + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + ] + + +class TestAsBool: """ Define :func:`colour.utilities.common.as_bool` definition unit tests methods. @@ -320,22 +330,22 @@ class TestAsBool(unittest.TestCase): def test_as_bool(self): """Test :func:`colour.utilities.common.as_bool` definition.""" - self.assertTrue(as_bool("1")) + assert as_bool("1") - self.assertTrue(as_bool("On")) + assert as_bool("On") - self.assertTrue(as_bool("True")) + assert as_bool("True") - self.assertFalse(as_bool("0")) + assert not as_bool("0") - self.assertFalse(as_bool("Off")) + assert not as_bool("Off") - self.assertFalse(as_bool("False")) + assert not as_bool("False") - self.assertFalse(as_bool("")) + assert not as_bool("") -class TestIsIterable(unittest.TestCase): +class TestIsIterable: """ Define :func:`colour.utilities.common.is_iterable` definition unit tests methods. @@ -344,28 +354,28 @@ class TestIsIterable(unittest.TestCase): def test_is_iterable(self): """Test :func:`colour.utilities.common.is_iterable` definition.""" - self.assertTrue(is_iterable("")) + assert is_iterable("") - self.assertTrue(is_iterable(())) + assert is_iterable(()) - self.assertTrue(is_iterable([])) + assert is_iterable([]) - self.assertTrue(is_iterable({})) + assert is_iterable({}) - self.assertTrue(is_iterable(set())) + assert is_iterable(set()) - self.assertTrue(is_iterable(np.array([]))) + assert is_iterable(np.array([])) - self.assertFalse(is_iterable(1)) + assert not is_iterable(1) - self.assertFalse(is_iterable(2)) + assert not is_iterable(2) generator = (a for a in range(10)) - self.assertTrue(is_iterable(generator)) - self.assertEqual(len(list(generator)), 10) + assert is_iterable(generator) + assert len(list(generator)) == 10 -class TestIsString(unittest.TestCase): +class TestIsString: """ Define :func:`colour.utilities.common.is_string` definition unit tests methods. @@ -374,20 +384,20 @@ class TestIsString(unittest.TestCase): def test_is_string(self): """Test :func:`colour.utilities.common.is_string` definition.""" - self.assertTrue(is_string("Hello World!")) + assert is_string("Hello World!") - self.assertTrue(is_string("Hello World!")) + assert is_string("Hello World!") - self.assertTrue(is_string(r"Hello World!")) + assert is_string(r"Hello World!") - self.assertFalse(is_string(1)) + assert not is_string(1) - self.assertFalse(is_string([1])) + assert not is_string([1]) - self.assertFalse(is_string({1: None})) + assert not is_string({1: None}) -class TestIsNumeric(unittest.TestCase): +class TestIsNumeric: """ Define :func:`colour.utilities.common.is_numeric` definition unit tests methods. @@ -396,18 +406,18 @@ class TestIsNumeric(unittest.TestCase): def test_is_numeric(self): """Test :func:`colour.utilities.common.is_numeric` definition.""" - self.assertTrue(is_numeric(1)) + assert is_numeric(1) - self.assertTrue(is_numeric(1)) + assert is_numeric(1) - self.assertFalse(is_numeric((1,))) + assert not is_numeric((1,)) - self.assertFalse(is_numeric([1])) + assert not is_numeric([1]) - self.assertFalse(is_numeric("1")) + assert not is_numeric("1") -class TestIsInteger(unittest.TestCase): +class TestIsInteger: """ Define :func:`colour.utilities.common.is_integer` definition unit tests methods. @@ -416,14 +426,14 @@ class TestIsInteger(unittest.TestCase): def test_is_integer(self): """Test :func:`colour.utilities.common.is_integer` definition.""" - self.assertTrue(is_integer(1)) + assert is_integer(1) - self.assertTrue(is_integer(1.001)) + assert is_integer(1.001) - self.assertFalse(is_integer(1.01)) + assert not is_integer(1.01) -class TestIsSibling(unittest.TestCase): +class TestIsSibling: """ Define :func:`colour.utilities.common.is_sibling` definition unit tests methods. @@ -450,12 +460,12 @@ def __init__(self, name: str) -> None: "Element C": Element("C"), } - self.assertTrue(is_sibling(Element("D"), mapping)) + assert is_sibling(Element("D"), mapping) - self.assertFalse(is_sibling(NotElement("Not D"), mapping)) + assert not is_sibling(NotElement("Not D"), mapping) -class TestFilterKwargs(unittest.TestCase): +class TestFilterKwargs: """ Define :func:`colour.utilities.common.filter_kwargs` definition unit tests methods. @@ -479,16 +489,16 @@ def fn_c(a: Any, b: float = 0, c: float = 0) -> Tuple[float, float, float]: return a, b, c - self.assertEqual(1, fn_a(1, **filter_kwargs(fn_a, b=2, c=3))) + assert fn_a(1, **filter_kwargs(fn_a, b=2, c=3)) == 1 - self.assertTupleEqual((1, 2), fn_b(1, **filter_kwargs(fn_b, b=2, c=3))) + assert fn_b(1, **filter_kwargs(fn_b, b=2, c=3)) == (1, 2) - self.assertTupleEqual((1, 2, 3), fn_c(1, **filter_kwargs(fn_c, b=2, c=3))) + assert fn_c(1, **filter_kwargs(fn_c, b=2, c=3)) == (1, 2, 3) - self.assertDictEqual(filter_kwargs(partial(fn_c, b=1), b=1), {"b": 1}) + assert filter_kwargs(partial(fn_c, b=1), b=1) == {"b": 1} -class TestFilterMapping(unittest.TestCase): +class TestFilterMapping: """ Define :func:`colour.utilities.common.filter_mapping` definition unit tests methods. @@ -510,11 +520,9 @@ def __init__(self, name: str) -> None: "Not Element C": Element("Not C"), } - self.assertListEqual( - sorted(filter_mapping(mapping, "Element A")), ["Element A"] - ) + assert sorted(filter_mapping(mapping, "Element A")) == ["Element A"] - self.assertDictEqual(filter_mapping(mapping, "Element"), {}) + assert filter_mapping(mapping, "Element") == {} mapping = CanonicalMapping( { @@ -525,18 +533,14 @@ def __init__(self, name: str) -> None: } ) - self.assertListEqual( - sorted(filter_mapping(mapping, "element a")), ["Element A"] - ) + assert sorted(filter_mapping(mapping, "element a")) == ["Element A"] - self.assertListEqual( - sorted(filter_mapping(mapping, "element-a")), ["Element A"] - ) + assert sorted(filter_mapping(mapping, "element-a")) == ["Element A"] - self.assertListEqual(sorted(filter_mapping(mapping, "elementa")), ["Element A"]) + assert sorted(filter_mapping(mapping, "elementa")) == ["Element A"] -class TestFirstItem(unittest.TestCase): +class TestFirstItem: """ Define :func:`colour.utilities.common.first_item` definition unit tests methods. @@ -545,15 +549,15 @@ class TestFirstItem(unittest.TestCase): def test_first_item(self): """Test :func:`colour.utilities.common.first_item` definition.""" - self.assertEqual(first_item(range(10)), 0) + assert first_item(range(10)) == 0 dictionary = {0: "a", 1: "b", 2: "c"} - self.assertEqual(first_item(dictionary.items()), (0, "a")) + assert first_item(dictionary.items()) == (0, "a") - self.assertEqual(first_item(dictionary.values()), "a") + assert first_item(dictionary.values()) == "a" -class TestValidateMethod(unittest.TestCase): +class TestValidateMethod: """ Define :func:`colour.utilities.common.validate_method` definition unit tests methods. @@ -562,7 +566,7 @@ class TestValidateMethod(unittest.TestCase): def test_validate_method(self): """Test :func:`colour.utilities.common.validate_method` definition.""" - self.assertEqual(validate_method("Valid", ("Valid", "Yes", "Ok")), "valid") + assert validate_method("Valid", ("Valid", "Yes", "Ok")) == "valid" def test_raise_exception_validate_method(self): """ @@ -570,12 +574,10 @@ def test_raise_exception_validate_method(self): exception. """ - self.assertRaises( - ValueError, validate_method, "Invalid", ("Valid", "Yes", "Ok") - ) + pytest.raises(ValueError, validate_method, "Invalid", ("Valid", "Yes", "Ok")) -class TestOptional(unittest.TestCase): +class TestOptional: """ Define :func:`colour.utilities.common.optional` definition unit tests methods. @@ -584,12 +586,12 @@ class TestOptional(unittest.TestCase): def test_optional(self): """Test :func:`colour.utilities.common.optional` definition.""" - self.assertEqual(optional("Foo", "Bar"), "Foo") + assert optional("Foo", "Bar") == "Foo" - self.assertEqual(optional(None, "Bar"), "Bar") + assert optional(None, "Bar") == "Bar" -class TestSlugify(unittest.TestCase): +class TestSlugify: """ Define :func:`colour.utilities.common.slugify` definition unit tests methods. @@ -598,35 +600,33 @@ class TestSlugify(unittest.TestCase): def test_slugify(self): """Test :func:`colour.utilities.common.slugify` definition.""" - self.assertEqual( - slugify( - " Jack & Jill like numbers 1,2,3 and 4 and silly characters ?%.$!/" - ), - "jack-jill-like-numbers-123-and-4-and-silly-characters", + assert ( + slugify(" Jack & Jill like numbers 1,2,3 and 4 and silly characters ?%.$!/") + == "jack-jill-like-numbers-123-and-4-and-silly-characters" ) - self.assertEqual( - slugify("Un \xe9l\xe9phant \xe0 l'or\xe9e du bois"), - "un-elephant-a-loree-du-bois", + assert ( + slugify("Un \xe9l\xe9phant \xe0 l'or\xe9e du bois") + == "un-elephant-a-loree-du-bois" ) # NOTE: Our "utilities/unicode_to_ascii.py" utility script normalises # the reference string. - self.assertEqual( + assert ( unicodedata.normalize( "NFD", slugify( "Un \xe9l\xe9phant \xe0 l'or\xe9e du bois", allow_unicode=True, ), - ), - "un-éléphant-à-lorée-du-bois", + ) + == "un-éléphant-à-lorée-du-bois" ) - self.assertEqual(slugify(123), "123") + assert slugify(123) == "123" -class TestIntDigest(unittest.TestCase): +class TestIntDigest: """ Define :func:`colour.utilities.common.int_digest` definition unit tests methods. @@ -635,19 +635,11 @@ class TestIntDigest(unittest.TestCase): def test_int_digest(self): """Test :func:`colour.utilities.common.int_digest` definition.""" - self.assertEqual(int_digest("Foo"), 7467386374397815550) + assert int_digest("Foo") == 7467386374397815550 if platform.system() in ("Windows", "Microsoft"): # pragma: no cover - self.assertEqual( - int_digest(np.array([1, 2, 3]).tobytes()), 7764052002911021640 - ) + assert int_digest(np.array([1, 2, 3]).tobytes()) == 7764052002911021640 else: - self.assertEqual( - int_digest(np.array([1, 2, 3]).tobytes()), 8964613590703056768 - ) - - self.assertEqual(int_digest(repr((1, 2, 3))), 5069958125469218295) - + assert int_digest(np.array([1, 2, 3]).tobytes()) == 8964613590703056768 -if __name__ == "__main__": - unittest.main() + assert int_digest(repr((1, 2, 3))) == 5069958125469218295 diff --git a/colour/utilities/tests/test_data_structures.py b/colour/utilities/tests/test_data_structures.py index 64afafa70..af602a6b8 100644 --- a/colour/utilities/tests/test_data_structures.py +++ b/colour/utilities/tests/test_data_structures.py @@ -3,9 +3,9 @@ import operator import pickle -import unittest import numpy as np +import pytest from colour.utilities import ( CanonicalMapping, @@ -32,7 +32,7 @@ ] -class TestStructure(unittest.TestCase): +class TestStructure: """ Define :class:`colour.utilities.data_structures.Structure` class unit tests methods. @@ -42,34 +42,34 @@ def test_Structure(self): """Test :class:`colour.utilities.data_structures.Structure` class.""" structure = Structure(John="Doe", Jane="Doe") - self.assertIn("John", structure) - self.assertTrue(hasattr(structure, "John")) + assert "John" in structure + assert hasattr(structure, "John") structure.John = "Nemo" - self.assertEqual(structure["John"], "Nemo") + assert structure["John"] == "Nemo" structure["John"] = "Vador" - self.assertEqual(structure["John"], "Vador") + assert structure["John"] == "Vador" del structure["John"] - self.assertNotIn("John", structure) - self.assertFalse(hasattr(structure, "John")) + assert "John" not in structure + assert not hasattr(structure, "John") structure.John = "Doe" - self.assertIn("John", structure) - self.assertTrue(hasattr(structure, "John")) + assert "John" in structure + assert hasattr(structure, "John") del structure.John - self.assertNotIn("John", structure) - self.assertFalse(hasattr(structure, "John")) + assert "John" not in structure + assert not hasattr(structure, "John") structure = Structure(John=None, Jane=None) - self.assertIsNone(structure.John) - self.assertIsNone(structure["John"]) + assert structure.John is None + assert structure["John"] is None structure.update(**{"John": "Doe", "Jane": "Doe"}) - self.assertEqual(structure.John, "Doe") - self.assertEqual(structure["John"], "Doe") + assert structure.John == "Doe" + assert structure["John"] == "Doe" def test_pickling(self): """ @@ -81,16 +81,16 @@ def test_pickling(self): data = pickle.dumps(structure) data = pickle.loads(data) # noqa: S301 - self.assertEqual(structure, data) + assert structure == data data = pickle.dumps(structure, pickle.HIGHEST_PROTOCOL) data = pickle.loads(data) # noqa: S301 - self.assertEqual(structure, data) + assert structure == data - self.assertEqual(sorted(dir(data)), ["Jane", "John"]) + assert sorted(dir(data)) == ["Jane", "John"] -class TestLookup(unittest.TestCase): +class TestLookup: """ Define :class:`colour.utilities.data_structures.Lookup` class unit tests methods. @@ -102,7 +102,7 @@ def test_required_methods(self): required_methods = ("keys_from_value", "first_key_from_value") for method in required_methods: - self.assertIn(method, dir(Lookup)) + assert method in dir(Lookup) def test_keys_from_value(self): """ @@ -111,14 +111,12 @@ def test_keys_from_value(self): """ lookup = Lookup(John="Doe", Jane="Doe", Luke="Skywalker") - self.assertListEqual(["Jane", "John"], sorted(lookup.keys_from_value("Doe"))) + assert ["Jane", "John"] == sorted(lookup.keys_from_value("Doe")) lookup = Lookup( A=np.array([0, 1, 2]), B=np.array([0, 1, 2]), C=np.array([1, 2, 3]) ) - self.assertListEqual( - ["A", "B"], sorted(lookup.keys_from_value(np.array([0, 1, 2]))) - ) + assert ["A", "B"] == sorted(lookup.keys_from_value(np.array([0, 1, 2]))) def test_first_key_from_value(self): """ @@ -127,12 +125,12 @@ def test_first_key_from_value(self): """ lookup = Lookup(first_name="John", last_name="Doe", gender="male") - self.assertEqual("first_name", lookup.first_key_from_value("John")) + assert lookup.first_key_from_value("John") == "first_name" lookup = Lookup( A=np.array([0, 1, 2]), B=np.array([1, 2, 3]), C=np.array([2, 3, 4]) ) - self.assertEqual("A", lookup.first_key_from_value(np.array([0, 1, 2]))) + assert lookup.first_key_from_value(np.array([0, 1, 2])) == "A" def test_raise_exception_first_key_from_value(self): """ @@ -140,10 +138,10 @@ def test_raise_exception_first_key_from_value(self): Lookup.first_key_from_value` method raised exception. """ - self.assertRaises(IndexError, Lookup().first_key_from_value, "John") + pytest.raises(IndexError, Lookup().first_key_from_value, "John") -class TestCanonicalMapping(unittest.TestCase): +class TestCanonicalMapping: """ Define :class:`colour.utilities.data_structures.CanonicalMapping` class unit tests methods. @@ -155,7 +153,7 @@ def test_required_attributes(self): required_attributes = ("data",) for attribute in required_attributes: - self.assertIn(attribute, dir(CanonicalMapping)) + assert attribute in dir(CanonicalMapping) def test_required_methods(self): """Test the presence of required methods.""" @@ -181,7 +179,7 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(CanonicalMapping)) + assert method in dir(CanonicalMapping) def test_data(self): """ @@ -189,10 +187,10 @@ def test_data(self): property. """ - self.assertDictEqual( - CanonicalMapping({"John": "Doe", "Jane": "Doe"}).data, - {"John": "Doe", "Jane": "Doe"}, - ) + assert CanonicalMapping({"John": "Doe", "Jane": "Doe"}).data == { + "John": "Doe", + "Jane": "Doe", + } def test__repr__(self): """ @@ -203,7 +201,7 @@ def test__repr__(self): mapping = CanonicalMapping() mapping["John"] = "Doe" - self.assertEqual(repr(mapping), "CanonicalMapping({'John': 'Doe'})") + assert repr(mapping) == "CanonicalMapping({'John': 'Doe'})" def test__setitem__(self): """ @@ -214,8 +212,8 @@ def test__setitem__(self): mapping = CanonicalMapping() mapping["John"] = "Doe" - self.assertEqual(mapping["John"], "Doe") - self.assertEqual(mapping["john"], "Doe") + assert mapping["John"] == "Doe" + assert mapping["john"] == "Doe" def test__getitem__(self): """ @@ -225,23 +223,23 @@ def test__getitem__(self): mapping = CanonicalMapping(John="Doe", Jane="Doe") - self.assertEqual(mapping["John"], "Doe") - self.assertEqual(mapping["john"], "Doe") - self.assertEqual(mapping["JOHN"], "Doe") - self.assertEqual(mapping["Jane"], "Doe") - self.assertEqual(mapping["jane"], "Doe") - self.assertEqual(mapping["JANE"], "Doe") + assert mapping["John"] == "Doe" + assert mapping["john"] == "Doe" + assert mapping["JOHN"] == "Doe" + assert mapping["Jane"] == "Doe" + assert mapping["jane"] == "Doe" + assert mapping["JANE"] == "Doe" mapping = CanonicalMapping({1: "Foo", 2: "Bar"}) - self.assertEqual(mapping[1], "Foo") + assert mapping[1] == "Foo" mapping = CanonicalMapping({"McCamy 1992": 1, "Hernandez 1999": 2}) - self.assertEqual(mapping["mccamy-1992"], 1) - self.assertEqual(mapping["hernandez-1999"], 2) - self.assertEqual(mapping["mccamy1992"], 1) - self.assertEqual(mapping["hernandez1999"], 2) + assert mapping["mccamy-1992"] == 1 + assert mapping["hernandez-1999"] == 2 + assert mapping["mccamy1992"] == 1 + assert mapping["hernandez1999"] == 2 def test__delitem__(self): """ @@ -252,39 +250,39 @@ def test__delitem__(self): mapping = CanonicalMapping(John="Doe", Jane="Doe") del mapping["john"] - self.assertNotIn("John", mapping) + assert "John" not in mapping del mapping["Jane"] - self.assertNotIn("jane", mapping) - self.assertEqual(len(mapping), 0) + assert "jane" not in mapping + assert len(mapping) == 0 mapping = CanonicalMapping(John="Doe", Jane="Doe") del mapping["JOHN"] - self.assertNotIn("John", mapping) + assert "John" not in mapping del mapping["jane"] - self.assertNotIn("jane", mapping) - self.assertEqual(len(mapping), 0) + assert "jane" not in mapping + assert len(mapping) == 0 mapping = CanonicalMapping({"McCamy 1992": 1, "Hernandez 1999": 2}) del mapping["mccamy-1992"] - self.assertNotIn("McCamy 1992", mapping) + assert "McCamy 1992" not in mapping del mapping["hernandez-1999"] - self.assertNotIn("Hernandez 1999", mapping) + assert "Hernandez 1999" not in mapping - self.assertEqual(len(mapping), 0) + assert len(mapping) == 0 mapping = CanonicalMapping({"McCamy 1992": 1, "Hernandez 1999": 2}) del mapping["mccamy1992"] - self.assertNotIn("McCamy 1992", mapping) + assert "McCamy 1992" not in mapping del mapping["hernandez1999"] - self.assertNotIn("Hernandez 1999", mapping) + assert "Hernandez 1999" not in mapping - self.assertEqual(len(mapping), 0) + assert len(mapping) == 0 def test__contains__(self): """ @@ -294,19 +292,19 @@ def test__contains__(self): mapping = CanonicalMapping(John="Doe", Jane="Doe") - self.assertIn("John", mapping) - self.assertIn("john", mapping) - self.assertIn("JOHN", mapping) - self.assertIn("Jane", mapping) - self.assertIn("jane", mapping) - self.assertIn("JANE", mapping) + assert "John" in mapping + assert "john" in mapping + assert "JOHN" in mapping + assert "Jane" in mapping + assert "jane" in mapping + assert "JANE" in mapping mapping = CanonicalMapping({"McCamy 1992": 1, "Hernandez 1999": 2}) - self.assertIn("mccamy-1992", mapping) - self.assertIn("hernandez-1999", mapping) - self.assertIn("mccamy1992", mapping) - self.assertIn("hernandez1999", mapping) + assert "mccamy-1992" in mapping + assert "hernandez-1999" in mapping + assert "mccamy1992" in mapping + assert "hernandez1999" in mapping def test__iter__(self): """ @@ -315,7 +313,7 @@ def test__iter__(self): """ mapping = CanonicalMapping(John="Doe", Jane="Doe") - self.assertListEqual(sorted(item for item in mapping), ["Jane", "John"]) + assert sorted(item for item in mapping) == ["Jane", "John"] def test__len__(self): """ @@ -323,9 +321,9 @@ def test__len__(self): method. """ - self.assertEqual(len(CanonicalMapping()), 0) + assert len(CanonicalMapping()) == 0 - self.assertEqual(len(CanonicalMapping(John="Doe", Jane="Doe")), 2) + assert len(CanonicalMapping(John="Doe", Jane="Doe")) == 2 def test__eq__(self): """ @@ -337,9 +335,9 @@ def test__eq__(self): mapping2 = CanonicalMapping(John="Doe", Jane="Doe") mapping3 = CanonicalMapping(john="Doe", jane="Doe") - self.assertEqual(mapping1, mapping2) + assert mapping1 == mapping2 - self.assertNotEqual(mapping2, mapping3) + assert mapping2 != mapping3 def test_raise_exception__eq__(self): """ @@ -347,7 +345,7 @@ def test_raise_exception__eq__(self): method raised exception. """ - self.assertRaises( + pytest.raises( TypeError, operator.eq, CanonicalMapping(John="Doe", Jane="Doe"), @@ -363,7 +361,7 @@ def test__ne__(self): mapping1 = CanonicalMapping(John="Doe", Jane="Doe") mapping2 = CanonicalMapping(Gi="Doe", Jane="Doe") - self.assertNotEqual(mapping1, mapping2) + assert mapping1 != mapping2 def test_raise_exception__ne__(self): """ @@ -371,7 +369,7 @@ def test_raise_exception__ne__(self): method raised exception. """ - self.assertRaises( + pytest.raises( TypeError, operator.ne, CanonicalMapping(John="Doe", Jane="Doe"), @@ -387,9 +385,9 @@ def test_copy(self): mapping1 = CanonicalMapping(John="Doe", Jane="Doe") mapping2 = mapping1.copy() - self.assertEqual(mapping1, mapping2) + assert mapping1 == mapping2 - self.assertNotEqual(id(mapping1), id(mapping2)) + assert id(mapping1) != id(mapping2) def test_lower_keys(self): """ @@ -399,14 +397,11 @@ def test_lower_keys(self): mapping = CanonicalMapping(John="Doe", Jane="Doe") - self.assertListEqual( - sorted(item for item in mapping.lower_keys()), - ["jane", "john"], - ) + assert sorted(item for item in mapping.lower_keys()) == ["jane", "john"] mapping = CanonicalMapping(John="Doe", john="Doe") - self.assertWarns(ColourUsageWarning, lambda: list(mapping.lower_keys())) + pytest.warns(ColourUsageWarning, lambda: list(mapping.lower_keys())) def test_lower_items(self): """ @@ -416,10 +411,10 @@ def test_lower_items(self): mapping = CanonicalMapping(John="Doe", Jane="Doe") - self.assertListEqual( - sorted(item for item in mapping.lower_items()), - [("jane", "Doe"), ("john", "Doe")], - ) + assert sorted(item for item in mapping.lower_items()) == [ + ("jane", "Doe"), + ("john", "Doe"), + ] def test_slugified_keys(self): """ @@ -429,14 +424,14 @@ def test_slugified_keys(self): mapping = CanonicalMapping({"McCamy 1992": 1, "Hernandez 1999": 2}) - self.assertListEqual( - sorted(item for item in mapping.slugified_keys()), - ["hernandez-1999", "mccamy-1992"], - ) + assert sorted(item for item in mapping.slugified_keys()) == [ + "hernandez-1999", + "mccamy-1992", + ] mapping = CanonicalMapping({"McCamy 1992": 1, "McCamy-1992": 2}) - self.assertWarns(ColourUsageWarning, lambda: list(mapping.slugified_keys())) + pytest.warns(ColourUsageWarning, lambda: list(mapping.slugified_keys())) def test_slugified_items(self): """ @@ -445,10 +440,10 @@ def test_slugified_items(self): """ mapping = CanonicalMapping({"McCamy 1992": 1, "Hernandez 1999": 2}) - self.assertListEqual( - sorted(item for item in mapping.slugified_items()), - [("hernandez-1999", 2), ("mccamy-1992", 1)], - ) + assert sorted(item for item in mapping.slugified_items()) == [ + ("hernandez-1999", 2), + ("mccamy-1992", 1), + ] def test_canonical_keys(self): """ @@ -458,14 +453,14 @@ def test_canonical_keys(self): mapping = CanonicalMapping({"McCamy 1992": 1, "Hernandez 1999": 2}) - self.assertListEqual( - sorted(item for item in mapping.canonical_keys()), - ["hernandez1999", "mccamy1992"], - ) + assert sorted(item for item in mapping.canonical_keys()) == [ + "hernandez1999", + "mccamy1992", + ] mapping = CanonicalMapping({"McCamy_1992": 1, "McCamy-1992": 2}) - self.assertWarns(ColourUsageWarning, lambda: list(mapping.canonical_keys())) + pytest.warns(ColourUsageWarning, lambda: list(mapping.canonical_keys())) def test_canonical_items(self): """ @@ -474,13 +469,13 @@ def test_canonical_items(self): """ mapping = CanonicalMapping({"McCamy 1992": 1, "Hernandez 1999": 2}) - self.assertListEqual( - sorted(item for item in mapping.canonical_items()), - [("hernandez1999", 2), ("mccamy1992", 1)], - ) + assert sorted(item for item in mapping.canonical_items()) == [ + ("hernandez1999", 2), + ("mccamy1992", 1), + ] -class TestLazyCanonicalMapping(unittest.TestCase): +class TestLazyCanonicalMapping: """ Define :class:`colour.utilities.data_structures.LazyCanonicalMapping` class unit tests methods. @@ -492,7 +487,7 @@ def test_required_attributes(self): required_attributes = () for attribute in required_attributes: # pragma: no cover - self.assertIn(attribute, dir(LazyCanonicalMapping)) + assert attribute in dir(LazyCanonicalMapping) def test_required_methods(self): """Test the presence of required methods.""" @@ -500,7 +495,7 @@ def test_required_methods(self): required_methods = ("__getitem__",) for method in required_methods: - self.assertIn(method, dir(LazyCanonicalMapping)) + assert method in dir(LazyCanonicalMapping) def test__getitem__(self): """ @@ -510,19 +505,19 @@ def test__getitem__(self): mapping = LazyCanonicalMapping(John="Doe", Jane=lambda: "Doe") - self.assertEqual(mapping["John"], "Doe") - self.assertEqual(mapping["john"], "Doe") - self.assertEqual(mapping["Jane"], "Doe") - self.assertEqual(mapping["jane"], "Doe") + assert mapping["John"] == "Doe" + assert mapping["john"] == "Doe" + assert mapping["Jane"] == "Doe" + assert mapping["jane"] == "Doe" -class TestNode(unittest.TestCase): +class TestNode: """ Define :class:`colour.utilities.data_structures.Node` class unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._data = {"John": "Doe"} @@ -553,7 +548,7 @@ def test_required_attributes(self): ) for attribute in required_attributes: - self.assertIn(attribute, dir(Node)) + assert attribute in dir(Node) def test_required_methods(self): """Test the presence of required methods.""" @@ -571,127 +566,114 @@ def test_required_methods(self): ) for method in required_methods: - self.assertIn(method, dir(Node)) + assert method in dir(Node) def test_name(self): """Test :attr:`colour.utilities.data_structures.Node.name` property.""" - self.assertEqual(self._tree.name, "Node A") - self.assertIn("Node#", Node().name) + assert self._tree.name == "Node A" + assert "Node#" in Node().name def test_parent(self): """Test :attr:`colour.utilities.data_structures.Node.parent` property.""" - self.assertIs(self._node_b.parent, self._node_a) - self.assertIs(self._node_h.parent, self._node_g) + assert self._node_b.parent is self._node_a + assert self._node_h.parent is self._node_g def test_children(self): """Test :attr:`colour.utilities.data_structures.Node.children` property.""" - self.assertListEqual(self._node_a.children, [self._node_b, self._node_c]) + assert self._node_a.children == [self._node_b, self._node_c] def test_id(self): """Test :attr:`colour.utilities.data_structures.Node.id` property.""" - self.assertIsInstance(self._node_a.id, int) + assert isinstance(self._node_a.id, int) def test_root(self): """Test :attr:`colour.utilities.data_structures.Node.root` property.""" - self.assertIs(self._node_a.root, self._node_a) - self.assertIs(self._node_f.root, self._node_a) - self.assertIs(self._node_g.root, self._node_a) - self.assertIs(self._node_h.root, self._node_a) + assert self._node_a.root is self._node_a + assert self._node_f.root is self._node_a + assert self._node_g.root is self._node_a + assert self._node_h.root is self._node_a def test_leaves(self): """Test :attr:`colour.utilities.data_structures.Node.leaves` property.""" - self.assertListEqual(list(self._node_h.leaves), [self._node_h]) + assert list(self._node_h.leaves) == [self._node_h] - self.assertListEqual( - list(self._node_a.leaves), - [self._node_h, self._node_e, self._node_c], - ) + assert list(self._node_a.leaves) == [self._node_h, self._node_e, self._node_c] def test_siblings(self): """Test :attr:`colour.utilities.data_structures.Node.siblings` property.""" - self.assertListEqual(list(self._node_a.siblings), []) + assert list(self._node_a.siblings) == [] - self.assertListEqual(list(self._node_b.siblings), [self._node_c]) + assert list(self._node_b.siblings) == [self._node_c] def test_data(self): """Test :attr:`colour.utilities.data_structures.Node.data` property.""" - self.assertIs(self._node_a.data, self._data) + assert self._node_a.data is self._data def test__str__(self): """Test :attr:`colour.utilities.data_structures.Node.__str__` method.""" - self.assertIn("Node#", str(self._node_a)) - self.assertIn("{'John': 'Doe'})", str(self._node_a)) + assert "Node#" in str(self._node_a) + assert "{'John': 'Doe'})" in str(self._node_a) def test__len__(self): """Test :attr:`colour.utilities.data_structures.Node.__len__` method.""" - self.assertEqual(len(self._node_a), 7) + assert len(self._node_a) == 7 def test_is_root(self): """Test :attr:`colour.utilities.data_structures.Node.is_root` method.""" - self.assertTrue(self._node_a.is_root()) - self.assertFalse(self._node_b.is_root()) - self.assertFalse(self._node_c.is_root()) - self.assertFalse(self._node_h.is_root()) + assert self._node_a.is_root() + assert not self._node_b.is_root() + assert not self._node_c.is_root() + assert not self._node_h.is_root() def test_is_inner(self): """Test :attr:`colour.utilities.data_structures.Node.is_inner` method.""" - self.assertFalse(self._node_a.is_inner()) - self.assertTrue(self._node_b.is_inner()) - self.assertFalse(self._node_c.is_inner()) - self.assertFalse(self._node_h.is_inner()) + assert not self._node_a.is_inner() + assert self._node_b.is_inner() + assert not self._node_c.is_inner() + assert not self._node_h.is_inner() def test_is_leaf(self): """Test :attr:`colour.utilities.data_structures.Node.is_leaf` method.""" - self.assertFalse(self._node_a.is_leaf()) - self.assertFalse(self._node_b.is_leaf()) - self.assertTrue(self._node_c.is_leaf()) - self.assertTrue(self._node_h.is_leaf()) + assert not self._node_a.is_leaf() + assert not self._node_b.is_leaf() + assert self._node_c.is_leaf() + assert self._node_h.is_leaf() def test_walk(self): """Test :attr:`colour.utilities.data_structures.Node.walk` method.""" - self.assertListEqual( - list(self._node_a.walk()), - [ - self._node_b, - self._node_d, - self._node_f, - self._node_g, - self._node_h, - self._node_e, - self._node_c, - ], - ) - - self.assertListEqual( - list(self._node_h.walk(ascendants=True)), - [ - self._node_g, - self._node_f, - self._node_d, - self._node_b, - self._node_a, - ], - ) + assert list(self._node_a.walk()) == [ + self._node_b, + self._node_d, + self._node_f, + self._node_g, + self._node_h, + self._node_e, + self._node_c, + ] + + assert list(self._node_h.walk(ascendants=True)) == [ + self._node_g, + self._node_f, + self._node_d, + self._node_b, + self._node_a, + ] def test_render(self): """Test :attr:`colour.utilities.data_structures.Node.render` method.""" - self.assertIsInstance(self._node_a.render(), str) - - -if __name__ == "__main__": - unittest.main() + assert isinstance(self._node_a.render(), str) diff --git a/colour/utilities/tests/test_deprecation.py b/colour/utilities/tests/test_deprecation.py index 88a599b0a..548f96968 100644 --- a/colour/utilities/tests/test_deprecation.py +++ b/colour/utilities/tests/test_deprecation.py @@ -2,7 +2,8 @@ """Define the unit tests for the :mod:`colour.utilities.deprecation` module.""" import sys -import unittest + +import pytest from colour.utilities import ColourUsageWarning from colour.utilities.deprecation import ( @@ -47,7 +48,7 @@ ] -class TestObjectRenamed(unittest.TestCase): +class TestObjectRenamed: """ Define :class:`colour.utilities.deprecation.ObjectRenamed` class unit tests methods. @@ -59,7 +60,7 @@ def test_required_methods(self): required_methods = ("__str__",) for method in required_methods: - self.assertIn(method, dir(ObjectRenamed)) + assert method in dir(ObjectRenamed) def test__str__(self): """ @@ -67,11 +68,11 @@ def test__str__(self): method. """ - self.assertIn("name", str(ObjectRenamed("name", "new_name"))) - self.assertIn("new_name", str(ObjectRenamed("name", "new_name"))) + assert "name" in str(ObjectRenamed("name", "new_name")) + assert "new_name" in str(ObjectRenamed("name", "new_name")) -class TestObjectRemoved(unittest.TestCase): +class TestObjectRemoved: """ Define :class:`colour.utilities.deprecation.ObjectRemoved` class unit tests methods. @@ -83,7 +84,7 @@ def test_required_methods(self): required_methods = ("__str__",) for method in required_methods: - self.assertIn(method, dir(ObjectRemoved)) + assert method in dir(ObjectRemoved) def test__str__(self): """ @@ -91,10 +92,10 @@ def test__str__(self): method. """ - self.assertIn("name", str(ObjectRemoved("name"))) + assert "name" in str(ObjectRemoved("name")) -class TestObjectFutureRename(unittest.TestCase): +class TestObjectFutureRename: """ Define :class:`colour.utilities.deprecation.ObjectFutureRename` class unit tests methods. @@ -106,7 +107,7 @@ def test_required_methods(self): required_methods = ("__str__",) for method in required_methods: - self.assertIn(method, dir(ObjectFutureRename)) + assert method in dir(ObjectFutureRename) def test__str__(self): """ @@ -114,11 +115,11 @@ def test__str__(self): method. """ - self.assertIn("name", str(ObjectFutureRename("name", "new_name"))) - self.assertIn("new_name", str(ObjectFutureRename("name", "new_name"))) + assert "name" in str(ObjectFutureRename("name", "new_name")) + assert "new_name" in str(ObjectFutureRename("name", "new_name")) -class TestObjectFutureRemove(unittest.TestCase): +class TestObjectFutureRemove: """ Define :class:`colour.utilities.deprecation.ObjectFutureRemove` class unit tests methods. @@ -130,7 +131,7 @@ def test_required_methods(self): required_methods = ("__str__",) for method in required_methods: - self.assertIn(method, dir(ObjectFutureRemove)) + assert method in dir(ObjectFutureRemove) def test__str__(self): """ @@ -138,17 +139,14 @@ def test__str__(self): method. """ - self.assertIn( - "name", - str( - ObjectFutureRemove( - "name", - ) - ), + assert "name" in str( + ObjectFutureRemove( + "name", + ) ) -class TestObjectFutureAccessChange(unittest.TestCase): +class TestObjectFutureAccessChange: """ Define :class:`colour.utilities.deprecation.ObjectFutureAccessChange` class unit tests methods. @@ -160,7 +158,7 @@ def test_required_methods(self): required_methods = ("__str__",) for method in required_methods: - self.assertIn(method, dir(ObjectFutureAccessChange)) + assert method in dir(ObjectFutureAccessChange) def test__str__(self): """ @@ -168,11 +166,11 @@ def test__str__(self): ObjectFutureAccessChange.__str__` method. """ - self.assertIn("name", str(ObjectFutureAccessChange("name", "new_access"))) - self.assertIn("new_access", str(ObjectFutureAccessChange("name", "new_access"))) + assert "name" in str(ObjectFutureAccessChange("name", "new_access")) + assert "new_access" in str(ObjectFutureAccessChange("name", "new_access")) -class TestObjectFutureAccessRemove(unittest.TestCase): +class TestObjectFutureAccessRemove: """ Define :class:`colour.utilities.deprecation.ObjectFutureAccessRemove` class unit tests methods. @@ -184,7 +182,7 @@ def test_required_methods(self): required_methods = ("__str__",) for method in required_methods: - self.assertIn(method, dir(ObjectFutureAccessRemove)) + assert method in dir(ObjectFutureAccessRemove) def test__str__(self): """ @@ -192,17 +190,14 @@ def test__str__(self): ObjectFutureAccessRemove.__str__` method. """ - self.assertIn( - "name", - str( - ObjectFutureAccessRemove( - "name", - ) - ), + assert "name" in str( + ObjectFutureAccessRemove( + "name", + ) ) -class TestArgumentRenamed(unittest.TestCase): +class TestArgumentRenamed: """ Define :class:`colour.utilities.deprecation.ArgumentRenamed` class unit tests methods. @@ -214,7 +209,7 @@ def test_required_methods(self): required_methods = ("__str__",) for method in required_methods: - self.assertIn(method, dir(ArgumentRenamed)) + assert method in dir(ArgumentRenamed) def test__str__(self): """ @@ -222,11 +217,11 @@ def test__str__(self): method. """ - self.assertIn("name", str(ArgumentRenamed("name", "new_name"))) - self.assertIn("new_name", str(ArgumentRenamed("name", "new_name"))) + assert "name" in str(ArgumentRenamed("name", "new_name")) + assert "new_name" in str(ArgumentRenamed("name", "new_name")) -class TestArgumentRemoved(unittest.TestCase): +class TestArgumentRemoved: """ Define :class:`colour.utilities.deprecation.ArgumentRemoved` class unit tests methods. @@ -238,7 +233,7 @@ def test_required_methods(self): required_methods = ("__str__",) for method in required_methods: - self.assertIn(method, dir(ArgumentRemoved)) + assert method in dir(ArgumentRemoved) def test__str__(self): """ @@ -246,10 +241,10 @@ def test__str__(self): method. """ - self.assertIn("name", str(ArgumentRemoved("name"))) + assert "name" in str(ArgumentRemoved("name")) -class TestArgumentFutureRename(unittest.TestCase): +class TestArgumentFutureRename: """ Define :class:`colour.utilities.deprecation.ArgumentFutureRename` class unit tests methods. @@ -261,7 +256,7 @@ def test_required_methods(self): required_methods = ("__str__",) for method in required_methods: - self.assertIn(method, dir(ArgumentFutureRename)) + assert method in dir(ArgumentFutureRename) def test__str__(self): """ @@ -269,11 +264,11 @@ def test__str__(self): ArgumentFutureRename.__str__` method. """ - self.assertIn("name", str(ArgumentFutureRename("name", "new_name"))) - self.assertIn("new_name", str(ArgumentFutureRename("name", "new_name"))) + assert "name" in str(ArgumentFutureRename("name", "new_name")) + assert "new_name" in str(ArgumentFutureRename("name", "new_name")) -class TestArgumentFutureRemove(unittest.TestCase): +class TestArgumentFutureRemove: """ Define :class:`colour.utilities.deprecation.ArgumentFutureRemove` class unit tests methods. @@ -285,7 +280,7 @@ def test_required_methods(self): required_methods = ("__str__",) for method in required_methods: - self.assertIn(method, dir(ArgumentFutureRemove)) + assert method in dir(ArgumentFutureRemove) def test__str__(self): """ @@ -293,17 +288,14 @@ def test__str__(self): ArgumentFutureRemove.__str__` method. """ - self.assertIn( - "name", - str( - ArgumentFutureRemove( - "name", - ) - ), + assert "name" in str( + ArgumentFutureRemove( + "name", + ) ) -class TestModuleAPI(unittest.TestCase): +class TestModuleAPI: """ Define :class:`colour.utilities.deprecation.ModuleAPI` class unit tests methods. @@ -315,7 +307,7 @@ def test_required_methods(self): required_methods = ("__init__", "__getattr__", "__dir__") for method in required_methods: - self.assertIn(method, dir(ModuleAPI)) + assert method in dir(ModuleAPI) def test__getattr__(self): """ @@ -325,14 +317,14 @@ def test__getattr__(self): import colour.utilities.tests.test_deprecated - self.assertIsNone(colour.utilities.tests.test_deprecated.NAME) + assert colour.utilities.tests.test_deprecated.NAME is None def assert_warns(): """Help to test the runtime warning.""" colour.utilities.tests.test_deprecated.OLD_NAME # noqa: B018 - self.assertWarns(ColourUsageWarning, assert_warns) + pytest.warns(ColourUsageWarning, assert_warns) del sys.modules["colour.utilities.tests.test_deprecated"] @@ -344,7 +336,7 @@ def test_raise_exception__getattr__(self): import colour.utilities.tests.test_deprecated - self.assertRaises( + pytest.raises( AttributeError, getattr, colour.utilities.tests.test_deprecated, @@ -354,7 +346,7 @@ def test_raise_exception__getattr__(self): del sys.modules["colour.utilities.tests.test_deprecated"] -class TestGetAttribute(unittest.TestCase): +class TestGetAttribute: """ Define :func:`colour.utilities.deprecation.get_attribute` definition unit tests methods. @@ -365,17 +357,15 @@ def test_get_attribute(self): from colour import adaptation - self.assertIs(get_attribute("colour.adaptation"), adaptation) + assert get_attribute("colour.adaptation") is adaptation from colour.models import eotf_inverse_sRGB - self.assertIs( - get_attribute("colour.models.eotf_inverse_sRGB"), eotf_inverse_sRGB - ) + assert get_attribute("colour.models.eotf_inverse_sRGB") is eotf_inverse_sRGB from colour.utilities.array import as_float - self.assertIs(get_attribute("colour.utilities.array.as_float"), as_float) + assert get_attribute("colour.utilities.array.as_float") is as_float if "colour.utilities.tests.test_deprecated" in sys.modules: # pragma: no cover del sys.modules["colour.utilities.tests.test_deprecated"] @@ -384,11 +374,11 @@ def test_get_attribute(self): import colour.utilities.tests.test_deprecated - self.assertIs(attribute, colour.utilities.tests.test_deprecated.NEW_NAME) + assert attribute is colour.utilities.tests.test_deprecated.NEW_NAME del sys.modules["colour.utilities.tests.test_deprecated"] -class TestBuildAPIChanges(unittest.TestCase): +class TestBuildAPIChanges: """ Define :func:`colour.utilities.deprecation.build_API_changes` definition unit tests methods. @@ -451,10 +441,10 @@ def test_build_API_changes(self): ("argument_3_name", ArgumentRemoved), ("argument_4_name", ArgumentFutureRemove), ): - self.assertIsInstance(changes[name], change_type) + assert isinstance(changes[name], change_type) -class TestHandleArgumentsDeprecation(unittest.TestCase): +class TestHandleArgumentsDeprecation: """ Define :func:`colour.utilities.deprecation.handle_arguments_deprecation` definition unit tests methods. @@ -483,23 +473,16 @@ def test_handle_arguments_deprecation(self): "ArgumentFutureRemove": ["argument_4_name"], } - self.assertDictEqual( - handle_arguments_deprecation( - changes, - argument_1_name=True, - argument_2_name=True, - argument_3_name=True, - argument_4_name=True, - argument_5_name=True, - ), - { - "argument_1_new_name": True, - "argument_2_new_name": True, - "argument_4_name": True, - "argument_5_name": True, - }, - ) - - -if __name__ == "__main__": - unittest.main() + assert handle_arguments_deprecation( + changes, + argument_1_name=True, + argument_2_name=True, + argument_3_name=True, + argument_4_name=True, + argument_5_name=True, + ) == { + "argument_1_new_name": True, + "argument_2_new_name": True, + "argument_4_name": True, + "argument_5_name": True, + } diff --git a/colour/utilities/tests/test_documentation.py b/colour/utilities/tests/test_documentation.py index e72b4b33f..4492502ba 100644 --- a/colour/utilities/tests/test_documentation.py +++ b/colour/utilities/tests/test_documentation.py @@ -2,7 +2,6 @@ """Define the unit tests for the :mod:`colour.utilities.documentation` module.""" import os -import unittest from colour.utilities.documentation import is_documentation_building @@ -18,7 +17,7 @@ ] -class TestIsDocumentationBuilding(unittest.TestCase): +class TestIsDocumentationBuilding: """ Define :func:`colour.utilities.documentation.is_documentation_building` definition unit tests methods. @@ -31,25 +30,25 @@ def test_is_documentation_building(self): """ try: - self.assertFalse(is_documentation_building()) + assert not is_documentation_building() os.environ["READTHEDOCS"] = "True" - self.assertTrue(is_documentation_building()) + assert is_documentation_building() os.environ["READTHEDOCS"] = "False" - self.assertTrue(is_documentation_building()) + assert is_documentation_building() del os.environ["READTHEDOCS"] - self.assertFalse(is_documentation_building()) + assert not is_documentation_building() os.environ["COLOUR_SCIENCE__DOCUMENTATION_BUILD"] = "True" - self.assertTrue(is_documentation_building()) + assert is_documentation_building() os.environ["COLOUR_SCIENCE__DOCUMENTATION_BUILD"] = "False" - self.assertTrue(is_documentation_building()) + assert is_documentation_building() del os.environ["COLOUR_SCIENCE__DOCUMENTATION_BUILD"] - self.assertFalse(is_documentation_building()) + assert not is_documentation_building() finally: # pragma: no cover if os.environ.get("READTHEDOCS"): @@ -57,7 +56,3 @@ def test_is_documentation_building(self): if os.environ.get("COLOUR_SCIENCE__DOCUMENTATION_BUILD"): del os.environ["COLOUR_SCIENCE__DOCUMENTATION_BUILD"] - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/utilities/tests/test_metrics.py b/colour/utilities/tests/test_metrics.py index 3d6e0ec47..2309326c1 100644 --- a/colour/utilities/tests/test_metrics.py +++ b/colour/utilities/tests/test_metrics.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.utilities.metrics` module.""" -import unittest import numpy as np @@ -21,7 +20,7 @@ ] -class TestMetricMse(unittest.TestCase): +class TestMetricMse: """ Define :func:`colour.utilities.metrics.metric_mse` definition unit tests methods. @@ -31,7 +30,7 @@ def test_metric_mse(self): """Test :func:`colour.utilities.metrics.metric_mse` definition.""" a = np.array([0.48222001, 0.31654775, 0.22070353]) - self.assertEqual(metric_mse(a, a), 0) + assert metric_mse(a, a) == 0 b = a * 0.9 np.testing.assert_allclose( @@ -48,7 +47,7 @@ def test_metric_mse(self): ) -class TestMetricPsnr(unittest.TestCase): +class TestMetricPsnr: """ Define :func:`colour.utilities.metrics.metric_psnr` definition unit tests methods. @@ -58,7 +57,7 @@ def test_metric_psnr(self): """Test :func:`colour.utilities.metrics.metric_psnr` definition.""" a = np.array([0.48222001, 0.31654775, 0.22070353]) - self.assertEqual(metric_psnr(a, a), 0) + assert metric_psnr(a, a) == 0 b = a * 0.9 np.testing.assert_allclose( @@ -73,7 +72,3 @@ def test_metric_psnr(self): 28.956851563141296, atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/utilities/tests/test_verbose.py b/colour/utilities/tests/test_verbose.py index 5e73b8855..76df69b1f 100644 --- a/colour/utilities/tests/test_verbose.py +++ b/colour/utilities/tests/test_verbose.py @@ -4,7 +4,6 @@ import os import sys import textwrap -import unittest from colour.hints import Optional from colour.utilities import ( @@ -34,7 +33,7 @@ ] -class TestShowWarning(unittest.TestCase): +class TestShowWarning: """ Define :func:`colour.utilities.verbose.show_warning` definition unit tests methods. @@ -56,7 +55,7 @@ def test_show_warning(self): sys.stderr = stderr -class TestSuppressWarnings(unittest.TestCase): +class TestSuppressWarnings: """ Define :func:`colour.utilities.verbose.suppress_warnings` definition unit tests methods. @@ -69,7 +68,7 @@ def test_suppress_warnings(self): warning("This is a suppressed unit test warning!") -class TestSuppressStdout(unittest.TestCase): +class TestSuppressStdout: """ Define :func:`colour.utilities.verbose.suppress_stdout` definition unit tests methods. @@ -82,7 +81,7 @@ def test_suppress_stdout(self): print("This is a suppressed message!") # noqa: T201 -class TestDescribeEnvironment(unittest.TestCase): +class TestDescribeEnvironment: """ Define :func:`colour.utilities.verbose.describe_environment` definition unit tests methods. @@ -92,34 +91,34 @@ def test_describe_environment(self): """Test :func:`colour.utilities.verbose.describe_environment` definition.""" environment = describe_environment() - self.assertIsInstance(environment, dict) - self.assertListEqual( - sorted(environment.keys()), - ["Interpreter", "Runtime", "colour-science.org"], - ) + assert isinstance(environment, dict) + assert sorted(environment.keys()) == [ + "Interpreter", + "Runtime", + "colour-science.org", + ] environment = describe_environment(development_packages=True) - self.assertListEqual( - sorted(environment.keys()), - ["Development", "Interpreter", "Runtime", "colour-science.org"], - ) + assert sorted(environment.keys()) == [ + "Development", + "Interpreter", + "Runtime", + "colour-science.org", + ] environment = describe_environment( development_packages=True, extras_packages=True ) - self.assertListEqual( - sorted(environment.keys()), - [ - "Development", - "Extras", - "Interpreter", - "Runtime", - "colour-science.org", - ], - ) + assert sorted(environment.keys()) == [ + "Development", + "Extras", + "Interpreter", + "Runtime", + "colour-science.org", + ] -class TestMultilineStr(unittest.TestCase): +class TestMultilineStr: """ Define :func:`colour.utilities.verbose.multiline_str` definition unit tests methods. @@ -162,8 +161,7 @@ def __str__(self) -> str: ], ) - self.assertEqual( - str(Data("Foo", 1, ["John", "Doe"])), + assert str(Data("Foo", 1, ["John", "Doe"])) == ( textwrap.dedent( """ Object - Data @@ -184,11 +182,11 @@ def __str__(self) -> str: ---- List "c" : John; Doe """ - ).strip(), + ).strip() ) -class TestMultilineRepr(unittest.TestCase): +class TestMultilineRepr: """ Define :func:`colour.utilities.verbose.multiline_repr` definition unit tests methods. @@ -225,8 +223,7 @@ def __repr__(self) -> str: ], ) - self.assertEqual( - repr(Data("Foo", 1, ["John", "Doe"])), + assert repr(Data("Foo", 1, ["John", "Doe"])) == ( textwrap.dedent( """ Data('Foo', @@ -234,9 +231,5 @@ def __repr__(self) -> str: ('John', 'Doe'), None) """ - ).strip(), + ).strip() ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/volume/tests/test_macadam_limits.py b/colour/volume/tests/test_macadam_limits.py index 346beff71..de78db054 100644 --- a/colour/volume/tests/test_macadam_limits.py +++ b/colour/volume/tests/test_macadam_limits.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.volume.macadam_limits` module.""" -import unittest from itertools import product import numpy as np @@ -21,7 +20,7 @@ ] -class TestIsWithinMacadamLimits(unittest.TestCase): +class TestIsWithinMacadamLimits: """ Define :func:`colour.volume.macadam_limits.is_within_macadam_limits` definition unit tests methods. @@ -33,21 +32,13 @@ def test_is_within_macadam_limits(self): definition. """ - self.assertTrue( - is_within_macadam_limits(np.array([0.3205, 0.4131, 0.5100]), "A") - ) + assert is_within_macadam_limits(np.array([0.3205, 0.4131, 0.5100]), "A") - self.assertFalse( - is_within_macadam_limits(np.array([0.0005, 0.0031, 0.0010]), "A") - ) + assert not is_within_macadam_limits(np.array([0.0005, 0.0031, 0.0010]), "A") - self.assertTrue( - is_within_macadam_limits(np.array([0.4325, 0.3788, 0.1034]), "C") - ) + assert is_within_macadam_limits(np.array([0.4325, 0.3788, 0.1034]), "C") - self.assertFalse( - is_within_macadam_limits(np.array([0.0025, 0.0088, 0.0340]), "C") - ) + assert not is_within_macadam_limits(np.array([0.0025, 0.0088, 0.0340]), "C") def test_n_dimensional_is_within_macadam_limits(self): """ @@ -76,7 +67,3 @@ def test_nan_is_within_macadam_limits(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) is_within_macadam_limits(cases, "A") - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/volume/tests/test_mesh.py b/colour/volume/tests/test_mesh.py index 8a0ecedb1..bd6d3159a 100644 --- a/colour/volume/tests/test_mesh.py +++ b/colour/volume/tests/test_mesh.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.volume.mesh` module.""" -import unittest from itertools import product import numpy as np @@ -22,13 +21,13 @@ ] -class TestIsWithinMeshVolume(unittest.TestCase): +class TestIsWithinMeshVolume: """ Define :func:`colour.volume.mesh.is_within_mesh_volume` definition unit tests methods. """ - def setUp(self): + def setup_method(self): """Initialise the common tests attributes.""" self._mesh = np.array( @@ -44,21 +43,13 @@ def setUp(self): def test_is_within_mesh_volume(self): """Test :func:`colour.volume.mesh.is_within_mesh_volume` definition.""" - self.assertTrue( - is_within_mesh_volume(np.array([0.0005, 0.0031, 0.0010]), self._mesh) - ) + assert is_within_mesh_volume(np.array([0.0005, 0.0031, 0.0010]), self._mesh) - self.assertFalse( - is_within_mesh_volume(np.array([0.3205, 0.4131, 0.5100]), self._mesh) - ) + assert not is_within_mesh_volume(np.array([0.3205, 0.4131, 0.5100]), self._mesh) - self.assertTrue( - is_within_mesh_volume(np.array([0.0025, 0.0088, 0.0340]), self._mesh) - ) + assert is_within_mesh_volume(np.array([0.0025, 0.0088, 0.0340]), self._mesh) - self.assertFalse( - is_within_mesh_volume(np.array([0.4325, 0.3788, 0.1034]), self._mesh) - ) + assert not is_within_mesh_volume(np.array([0.4325, 0.3788, 0.1034]), self._mesh) def test_n_dimensional_is_within_mesh_volume(self): """ @@ -95,7 +86,3 @@ def test_nan_is_within_mesh_volume(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) is_within_mesh_volume(cases, self._mesh) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/volume/tests/test_pointer_gamut.py b/colour/volume/tests/test_pointer_gamut.py index c930c4096..a850d17dc 100644 --- a/colour/volume/tests/test_pointer_gamut.py +++ b/colour/volume/tests/test_pointer_gamut.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.volume.pointer_gamut` module.""" -import unittest from itertools import product import numpy as np @@ -21,7 +20,7 @@ ] -class TestIsWithinPointerGamut(unittest.TestCase): +class TestIsWithinPointerGamut: """ Define :func:`colour.volume.pointer_gamut.is_within_pointer_gamut` definition unit tests methods. @@ -33,13 +32,13 @@ def test_is_within_pointer_gamut(self): definition. """ - self.assertTrue(is_within_pointer_gamut(np.array([0.3205, 0.4131, 0.5100]))) + assert is_within_pointer_gamut(np.array([0.3205, 0.4131, 0.5100])) - self.assertFalse(is_within_pointer_gamut(np.array([0.0005, 0.0031, 0.0010]))) + assert not is_within_pointer_gamut(np.array([0.0005, 0.0031, 0.0010])) - self.assertTrue(is_within_pointer_gamut(np.array([0.4325, 0.3788, 0.1034]))) + assert is_within_pointer_gamut(np.array([0.4325, 0.3788, 0.1034])) - self.assertFalse(is_within_pointer_gamut(np.array([0.0025, 0.0088, 0.0340]))) + assert not is_within_pointer_gamut(np.array([0.0025, 0.0088, 0.0340])) def test_n_dimensional_is_within_pointer_gamut(self): """ @@ -68,7 +67,3 @@ def test_nan_is_within_pointer_gamut(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) is_within_pointer_gamut(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/volume/tests/test_rgb.py b/colour/volume/tests/test_rgb.py index bac97a192..d92949b54 100644 --- a/colour/volume/tests/test_rgb.py +++ b/colour/volume/tests/test_rgb.py @@ -18,7 +18,6 @@ reproducibility-of-python-pseudo-random-numbers-across-systems-and-versions """ -import unittest import numpy as np @@ -54,7 +53,7 @@ ] -class TestRGB_colourspaceLimits(unittest.TestCase): +class TestRGB_colourspaceLimits: """ Define :func:`colour.volume.rgb.RGB_colourspace_limits` definition unit tests methods. @@ -100,7 +99,7 @@ def test_RGB_colourspace_limits(self): ) -class TestRGB_colourspaceVolumeMonteCarlo(unittest.TestCase): +class TestRGB_colourspaceVolumeMonteCarlo: """ Define :func:`colour.volume.rgb.RGB_colourspace_volume_MonteCarlo` definition unit tests methods. @@ -129,7 +128,7 @@ def test_RGB_colourspace_volume_MonteCarlo(self): ) -class TestRGB_colourspace_volume_coverage_MonteCarlo(unittest.TestCase): +class TestRGB_colourspace_volume_coverage_MonteCarlo: """ Define :func:`colour.volume.rgb.\ RGB_colourspace_volume_coverage_MonteCarlo` definition unit tests methods. @@ -157,7 +156,7 @@ def test_RGB_colourspace_volume_coverage_MonteCarlo(self): ) -class TestRGB_colourspacePointerGamutCoverageMonteCarlo(unittest.TestCase): +class TestRGB_colourspacePointerGamutCoverageMonteCarlo: """ Define :func:`colour.volume.rgb.\ RGB_colourspace_pointer_gamut_coverage_MonteCarlo` definition unit tests @@ -185,7 +184,7 @@ def test_RGB_colourspace_pointer_gamut_coverage_MonteCarlo(self): ) -class TestRGB_colourspaceVisibleSpectrumCoverageMonteCarlo(unittest.TestCase): +class TestRGB_colourspaceVisibleSpectrumCoverageMonteCarlo: """ Define :func:`colour.volume.rgb.\ RGB_colourspace_visible_spectrum_coverage_MonteCarlo` definition unit tests @@ -211,7 +210,3 @@ def test_RGB_colourspace_visible_spectrum_coverage_MonteCarlo(self): 46.931407942238266, atol=TOLERANCE_ABSOLUTE_TESTS, ) - - -if __name__ == "__main__": - unittest.main() diff --git a/colour/volume/tests/test_spectrum.py b/colour/volume/tests/test_spectrum.py index 671a2f285..7ce7ef2b2 100644 --- a/colour/volume/tests/test_spectrum.py +++ b/colour/volume/tests/test_spectrum.py @@ -1,7 +1,6 @@ # !/usr/bin/env python """Define the unit tests for the :mod:`colour.volume.spectrum` module.""" -import unittest from itertools import product import numpy as np @@ -34,7 +33,7 @@ ] -class TestGeneratePulseWaves(unittest.TestCase): +class TestGeneratePulseWaves: """ Define :func:`colour.volume.spectrum.generate_pulse_waves` definition unit tests methods. @@ -132,7 +131,7 @@ def test_generate_pulse_waves(self): ) -class TestXYZOuterSurface(unittest.TestCase): +class TestXYZOuterSurface: """ Define :func:`colour.volume.spectrum.XYZ_outer_surface` definition unit tests methods. @@ -191,7 +190,7 @@ def test_XYZ_outer_surface(self): ) -class TestIsWithinVisibleSpectrum(unittest.TestCase): +class TestIsWithinVisibleSpectrum: """ Define :func:`colour.volume.spectrum.is_within_visible_spectrum` definition unit tests methods. @@ -203,15 +202,13 @@ def test_is_within_visible_spectrum(self): definition. """ - self.assertTrue(is_within_visible_spectrum(np.array([0.3205, 0.4131, 0.5100]))) + assert is_within_visible_spectrum(np.array([0.3205, 0.4131, 0.5100])) - self.assertFalse( - is_within_visible_spectrum(np.array([-0.0005, 0.0031, 0.0010])) - ) + assert not is_within_visible_spectrum(np.array([-0.0005, 0.0031, 0.0010])) - self.assertTrue(is_within_visible_spectrum(np.array([0.4325, 0.3788, 0.1034]))) + assert is_within_visible_spectrum(np.array([0.4325, 0.3788, 0.1034])) - self.assertFalse(is_within_visible_spectrum(np.array([0.0025, 0.0088, 0.0340]))) + assert not is_within_visible_spectrum(np.array([0.0025, 0.0088, 0.0340])) def test_n_dimensional_is_within_visible_spectrum(self): """ @@ -240,7 +237,3 @@ def test_nan_is_within_visible_spectrum(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) is_within_visible_spectrum(cases) - - -if __name__ == "__main__": - unittest.main() diff --git a/pyproject.toml b/pyproject.toml index 6e069f8f6..7c3c6e84b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -219,6 +219,7 @@ convention = "numpy" "colour/examples/*" = ["INP", "T201", "T203"] "docs/*" = ["INP"] "tasks.py" = ["INP"] +"test_*" = ["S101"] "utilities/*" = ["EXE001", "INP"] "utilities/unicode_to_ascii.py" = ["RUF001"]