Coverage for continuous/tests/test_abstract.py: 67%

1"""Define the unit tests for the :mod:`colour.continuous.abstract` module."""

2

3 from __future__ import annotations

4

5 from colour.continuous import AbstractContinuousFunction

6

7 __author__ = "Colour Developers"

8 __copyright__ = "Copyright 2013 Colour Developers"

9 __license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"

10 __maintainer__ = "Colour Developers"

11 __email__ = "colour-developers@colour-science.org"

12 __status__ = "Production"

13

14 __all__ = [

15 "AbstractTestContinuousFunction",

16]

17

18

19 class AbstractTestContinuousFunction:

20 """

21 Define :class:`colour.continuous.abstract.AbstractContinuousFunction`

22 class unit tests methods.

23 """

24

25 def test_required_attributes(self) -> None:

26 """Test the presence of required attributes."""

27

28 required_attributes = (

29 "name",

30 "domain",

31 "range",

32 "interpolator",

33 "interpolator_kwargs",

34 "extrapolator",

35 "extrapolator_kwargs",

36 "function",

37 )

38

39 for attribute in required_attributes:

40 assert attribute in dir(AbstractContinuousFunction)

41

42 def test_required_methods(self) -> None:

43 """Test the presence of required methods."""

44

45 required_methods = (

46 "__init__",

47 "__str__",

48 "__repr__",

49 "__hash__",

50 "__getitem__",

51 "__setitem__",

52 "__contains__",

53 "__iter__",

54 "__len__",

55 "__eq__",

56 "__ne__",

57 "__iadd__",

58 "__add__",

59 "__isub__",

60 "__sub__",

61 "__imul__",

62 "__mul__",

63 "__idiv__",

64 "__div__",

65 "__ipow__",

66 "__pow__",

67 "arithmetical_operation",

68 "fill_nan",

69 "domain_distance",

70 "is_uniform",

71 "copy",

72 )

73

74 for method in required_methods:

75 assert method in dir(AbstractContinuousFunction)