Coverage for colour/plotting/conftest.py: 100%
16 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"""
2Plotting - Pytest Configuration
3===============================
5Configure *pytest* to use the *Matplotlib* *AGG* headless backend. This
6enables the plotting unit tests to run without creating windows in IDEs such
7as *VSCode*.
8"""
10import matplotlib as mpl
11import pytest
13from colour.hints import Generator
15__author__ = "Colour Developers"
16__copyright__ = "Copyright 2013 Colour Developers"
17__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
18__maintainer__ = "Colour Developers"
19__email__ = "colour-developers@colour-science.org"
20__status__ = "Production"
22__all__ = [
23 "mpl_headless_backend",
24]
27@pytest.fixture(autouse=True, scope="session")
28def mpl_headless_backend() -> Generator[None, None, None]:
29 """
30 Configure *Matplotlib* for headless testing.
32 This pytest fixture is automatically applied to any tests in this
33 package or any subpackages at the beginning of the pytest session.
35 Yields
36 ------
37 Generator
38 *Matplotlib* unit tests.
39 """
41 current_backend = mpl.get_backend()
42 mpl.use("AGG")
43 yield
44 mpl.use(current_backend)