Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: avoid using high level (and thread-unsafe) pyplot API in tests #193

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
import pytest
from matplotlib.figure import Figure

import cmyt
from cmyt._utils import cmyt_cmaps, prefix_name
Expand All @@ -25,7 +26,8 @@ def example_data():
@mpl_compare
@pytest.mark.parametrize("name", cmyt_cmaps)
def test_from_str(name, example_data):
fig, axes = plt.subplots(ncols=2, figsize=(12, 4))
fig = Figure(figsize=(12, 4))
axes = fig.subplots(ncols=2)
pname = prefix_name(name)
for cmap, ax in zip([pname, f"{pname}_r"], axes, strict=True):
ax.set_title(cmap)
Expand All @@ -37,7 +39,8 @@ def test_from_str(name, example_data):
@mpl_compare
@pytest.mark.parametrize("name", cmyt_cmaps)
def test_from_obj(name, example_data):
fig, axes = plt.subplots(ncols=2, figsize=(12, 4))
fig = Figure(figsize=(12, 4))
axes = fig.subplots(ncols=2)
for cmap, ax in zip([name, f"{name}_r"], axes, strict=True):
ax.set_title(cmap)
im = ax.imshow(example_data, cmap=getattr(cmyt, cmap))
Expand All @@ -48,4 +51,4 @@ def test_from_obj(name, example_data):
@pytest.mark.parametrize("name", cmyt_cmaps)
def test_cmap_name_attr(name):
assert getattr(cmyt, name).name == name
assert plt.get_cmap(f"cmyt.{name}").name == prefix_name(name)
assert mpl.colormaps[f"cmyt.{name}"].name == prefix_name(name)