Skip to content

Commit 0619191

Browse files
committed
Fix: matplotlib in windows CI
1 parent 2d9c32d commit 0619191

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

tests/plotting/shared.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from physt.histogram_nd import Histogram2D
99

1010

11-
class AbstractTest(ABC):
11+
class AbstractPlottingTest(ABC):
1212
module: Any
1313
function_name: str
1414

@@ -21,7 +21,7 @@ def assert_valid_output(self, output) -> None:
2121
...
2222

2323

24-
class AbstractTest1D(AbstractTest, ABC):
24+
class AbstractTest1D(AbstractPlottingTest, ABC):
2525
def test_2d_fail(self, simple_h2: "Histogram2D", default_kwargs):
2626
with pytest.raises(TypeError):
2727
self.method(simple_h2, **default_kwargs)
@@ -30,7 +30,7 @@ def test_simple_does_not_fail(self, simple_h1, default_kwargs):
3030
_ = self.method(simple_h1, **default_kwargs)
3131

3232

33-
class AbstractTest2D(AbstractTest, ABC):
33+
class AbstractTest2D(AbstractPlottingTest, ABC):
3434
def test_1d_fail(self, simple_h1: "Histogram1D", default_kwargs):
3535
with pytest.raises(TypeError):
3636
self.method(simple_h1, **default_kwargs)

tests/plotting/test_matplotlib.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@
77

88
from physt.plotting import matplotlib
99

10-
from .shared import AbstractTest, AbstractTest1D, AbstractTest2D
10+
from .shared import AbstractPlottingTest, AbstractTest1D, AbstractTest2D
1111

1212

13-
class _TestBase(AbstractTest, ABC):
13+
@pytest.fixture(autouse=True)
14+
def setup_matplotlib():
15+
import matplotlib
16+
17+
matplotlib.use("Agg")
18+
19+
20+
class _TestBase(AbstractPlottingTest, ABC):
1421
module = matplotlib
1522

1623
def assert_valid_output(self, output) -> None:

tests/plotting/test_plotly.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88

99
from physt.plotting import plotly
1010

11-
from .shared import AbstractTest, AbstractTest1D, AbstractTest2D
11+
from .shared import AbstractPlottingTest, AbstractTest1D, AbstractTest2D
1212

1313

1414
@pytest.fixture()
1515
def default_kwargs() -> Dict[str, Any]:
1616
return {}
1717

1818

19-
class _TestBase(AbstractTest, ABC):
19+
class _TestBase(AbstractPlottingTest, ABC):
2020
module = plotly
2121

2222
def assert_valid_output(self, output):

tests/plotting/test_vega.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
from physt.plotting import vega
88

9-
from .shared import AbstractTest, AbstractTest1D, AbstractTest2D
9+
from .shared import AbstractPlottingTest, AbstractTest1D, AbstractTest2D
1010

1111
if TYPE_CHECKING:
1212
from physt.histogram1d import Histogram1D
1313
from physt.histogram_nd import Histogram2D
1414

1515

16-
class _TestBase(AbstractTest, ABC):
16+
class _TestBase(AbstractPlottingTest, ABC):
1717
module = vega
1818

1919
def assert_valid_output(self, output):

0 commit comments

Comments
 (0)