Skip to content

Commit

Permalink
fixed matplotlib backend on testing
Browse files Browse the repository at this point in the history
  • Loading branch information
juanbc committed Feb 9, 2024
1 parent 32b59c8 commit 66596a7
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import functools


import matplotlib as mpl

import numpy as np

import pytest
Expand Down Expand Up @@ -141,3 +143,50 @@ def make(**kwargs):
return dm

return make


# =============================================================================
# MARKERS
# =============================================================================


MARKERS = [
("posix", "os.name != 'posix'", "Requires a POSIX os"),
("not_posix", "os.name == 'posix'", "Skipped on POSIX"),
("windows", "os.name != 'nt'", "Requires Windows"),
("not_windows", "os.name == 'nt'", "Skipped on Windows"),
("linux", "not sys.platform.startswith('linux')", "Requires Linux"),
("not_linux", "sys.platform.startswith('linux')", "Skipped on Linux"),
("osx", "sys.platform != 'darwin'", "Requires OS X"),
("not_osx", "sys.platform == 'darwin'", "Skipped on OS X"),
]


def pytest_configure(config):
for marker, _, reason in MARKERS:
config.addinivalue_line("markers", "{}: {}".format(marker, reason))


def pytest_collection_modifyitems(items):
for item in items:
for searched_marker, condition, default_reason in MARKERS:
marker = item.get_closest_marker(searched_marker)
if not marker:
continue

if "reason" in marker.kwargs:
reason = "{}: {}".format(
default_reason, marker.kwargs["reason"]
)
else:
reason = default_reason + "."
skipif_marker = pytest.mark.skipif(condition, reason=reason)
item.add_marker(skipif_marker)


# =============================================================================
# CI
# =============================================================================


mpl.use("Agg")

0 comments on commit 66596a7

Please sign in to comment.