Coverage for colour/utilities/tests/test_deprecated.py: 100%
18 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-15 19:01 +1300
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-15 19:01 +1300
1"""Define the unit tests helper module for the deprecation management."""
3from __future__ import annotations
5import contextlib
6import sys
7import typing
9if typing.TYPE_CHECKING:
10 from colour.hints import Any
12from colour.utilities.deprecation import ModuleAPI, ObjectRemoved, ObjectRenamed
15class deprecated(ModuleAPI):
16 """Define a class acting like the *deprecated* module."""
18 def __getattr__(self, attribute: str) -> Any:
19 """Return the value from the attribute with the specified name."""
21 return super().__getattr__(attribute)
24NAME: Any = None
25"""An non-deprecated module attribute."""
27NEW_NAME: Any = None
28"""A module attribute with a new name."""
30with contextlib.suppress(KeyError):
31 sys.modules["colour.utilities.tests.test_deprecated"] = deprecated( # pyright: ignore
32 sys.modules["colour.utilities.tests.test_deprecated"],
33 {
34 "OLD_NAME": ObjectRenamed(
35 name="colour.utilities.tests.test_deprecated.OLD_NAME",
36 new_name="colour.utilities.tests.test_deprecated.NEW_NAME",
37 ),
38 "REMOVED": ObjectRemoved(
39 name="colour.utilities.tests.test_deprecated.REMOVED"
40 ),
41 },
42 )
44del ModuleAPI
45del ObjectRenamed
46del ObjectRemoved
47del sys