Skip to content

Commit

Permalink
BUG: Fix legend bgcolor and Travis macOS (#8017)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner authored Jul 16, 2020
1 parent 056c273 commit c70260f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
21 changes: 16 additions & 5 deletions mne/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,24 @@ def __init__(self, exception_handler=None):
cbook.CallbackRegistry = CallbackRegistryReraise


@pytest.fixture(scope='session')
def travis_macos():
"""Determine if running on Travis macOS."""
return (os.getenv('TRAVIS', 'false').lower() == 'true' and
sys.platform == 'darwin')


@pytest.fixture(scope='session')
def azure_windows():
"""Determine if running on Azure Windows."""
return (os.getenv('AZURE_CI_WINDOWS', 'false').lower() == 'true' and
sys.platform.startswith('win'))


@pytest.fixture()
def check_gui_ci():
def check_gui_ci(travis_macos, azure_windows):
"""Skip tests that are not reliable on CIs."""
osx = (os.getenv('TRAVIS', 'false').lower() == 'true' and
sys.platform == 'darwin')
win = os.getenv('AZURE_CI_WINDOWS', 'false').lower() == 'true'
if win or osx:
if azure_windows or travis_macos:
pytest.skip('Skipping GUI tests on Travis OSX and Azure Windows')


Expand Down
8 changes: 6 additions & 2 deletions mne/viz/_brain/_timeviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ def plot_time_line(self, x, label, **kwargs):

def update_plot(self):
"""Update the plot."""
self.axes.legend(prop={'family': 'monospace', 'size': 'small'},
framealpha=0.5, handlelength=1.)
leg = self.axes.legend(
prop={'family': 'monospace', 'size': 'small'},
framealpha=0.5, handlelength=1.,
facecolor=self.time_viewer.brain._bg_color)
for text in leg.get_texts():
text.set_color(self.time_viewer.brain._fg_color)
self.canvas.draw()

def set_color(self, bg_color, fg_color):
Expand Down
12 changes: 7 additions & 5 deletions mne/viz/_brain/tests/test_brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def test_brain(renderer):
def test_brain_save_movie(tmpdir, renderer):
"""Test saving a movie of a _Brain instance."""
if renderer._get_3d_backend() == "mayavi":
pytest.skip()
pytest.skip('Save movie only supported on PyVista')
brain_data = _create_testing_brain(hemi='lh')
filename = str(path.join(tmpdir, "brain_test.mov"))
brain_data.save_movie(filename, time_dilation=1,
Expand All @@ -166,7 +166,7 @@ def test_brain_save_movie(tmpdir, renderer):
def test_brain_timeviewer(renderer_interactive):
"""Test _TimeViewer primitives."""
if renderer_interactive._get_3d_backend() != 'pyvista':
pytest.skip()
pytest.skip('TimeViewer tests only supported on PyVista')
brain_data = _create_testing_brain(hemi='both')

time_viewer = _TimeViewer(brain_data)
Expand Down Expand Up @@ -201,7 +201,7 @@ def test_brain_timeviewer(renderer_interactive):
def test_brain_timeviewer_traces(renderer_interactive, hemi):
"""Test _TimeViewer traces."""
if renderer_interactive._get_3d_backend() != 'pyvista':
pytest.skip()
pytest.skip('Only PyVista supports traces')
brain_data = _create_testing_brain(hemi=hemi)
time_viewer = _TimeViewer(brain_data, show_traces=True)
assert hasattr(time_viewer, "picked_points")
Expand Down Expand Up @@ -253,10 +253,12 @@ def test_brain_timeviewer_traces(renderer_interactive, hemi):


@testing.requires_testing_data
def test_brain_linkviewer(renderer_interactive):
def test_brain_linkviewer(renderer_interactive, travis_macos):
"""Test _LinkViewer primitives."""
if renderer_interactive._get_3d_backend() != 'pyvista':
pytest.skip()
pytest.skip('Linkviewer only supported on PyVista')
if travis_macos:
pytest.skip('Linkviewer tests unstable on Travis macOS')
brain_data = _create_testing_brain(hemi='split')
_TimeViewer(brain_data)

Expand Down

0 comments on commit c70260f

Please sign in to comment.