Coverage for utilities/tests/test_documentation.py: 100%

1"""Define the unit tests for the :mod:`colour.utilities.documentation` module."""

2

3 from __future__ import annotations

4

5 import os

6

7 from colour.utilities.documentation import is_documentation_building

8

9 __author__ = "Colour Developers"

10 __copyright__ = "Copyright 2013 Colour Developers"

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

12 __maintainer__ = "Colour Developers"

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

14 __status__ = "Production"

15

16 __all__ = [

17 "TestIsDocumentationBuilding",

18]

19

20

21 class TestIsDocumentationBuilding:

22 """

23 Define :func:`colour.utilities.documentation.is_documentation_building`

24 definition unit tests methods.

25 """

26

27 def test_is_documentation_building(self) -> None:

28 """

29 Test :func:`colour.utilities.documentation.is_documentation_building`

30 definition.

31 """

32

33 try:

34 assert not is_documentation_building()

35

36 os.environ["READTHEDOCS"] = "True"

37 assert is_documentation_building()

38

39 os.environ["READTHEDOCS"] = "False"

40 assert is_documentation_building()

41

42 del os.environ["READTHEDOCS"]

43 assert not is_documentation_building()

44

45 os.environ["COLOUR_SCIENCE__DOCUMENTATION_BUILD"] = "True"

46 assert is_documentation_building()

47

48 os.environ["COLOUR_SCIENCE__DOCUMENTATION_BUILD"] = "False"

49 assert is_documentation_building()

50

51 del os.environ["COLOUR_SCIENCE__DOCUMENTATION_BUILD"]

52 assert not is_documentation_building()

53

54 finally: # pragma: no cover

55 if os.environ.get("READTHEDOCS"):

56 del os.environ["READTHEDOCS"]

57

58 if os.environ.get("COLOUR_SCIENCE__DOCUMENTATION_BUILD"):

59 del os.environ["COLOUR_SCIENCE__DOCUMENTATION_BUILD"]