Skip to content

Commit

Permalink
Add conftest.py file.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Oct 27, 2023
1 parent eaf8e98 commit 95b9c78
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions colour_visuals/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""
Pytest Configuration
====================
Configures *pytest* to use the *Matplotlib* *AGG* headless backend. This allows
the plotting unittests to run without creating windows in IDEs such as
*VSCode*.
"""

import matplotlib as mpl
import pytest
from colour.hints import Generator

__author__ = "Colour Developers"
__copyright__ = "Copyright 2013 Colour Developers"
__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
__maintainer__ = "Colour Developers"
__email__ = "[email protected]"
__status__ = "Production"

__all__ = [
"mpl_headless_backend",
]


@pytest.fixture(autouse=True, scope="session")
def mpl_headless_backend() -> Generator[None, None, None]:
"""
Configure *Matplotlib* for headless testing.
This pytest fixture is automatically applied to any tests in this package
or any subpackages at the beginning of the pytest session.
Yields
------
Generator
*Matplotlib* unit tests.
"""

current_backend = mpl.get_backend()
mpl.use("AGG")
yield
mpl.use(current_backend)

0 comments on commit 95b9c78

Please sign in to comment.