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

Fix pyqtgraph in CI #23

Merged
merged 5 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install pyqtgraph dependencies
# https://pytest-qt.readthedocs.io/en/latest/troubleshooting.html#github-actions
uses: tlambert03/setup-qt-libs@v1
- name: Setup headless display
uses: pyvista/setup-headless-display-action@v2
- name: Install poetry
run: pipx install poetry==1.7.1
- name: Set up Python
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install pyqtgraph dependencies
# https://pytest-qt.readthedocs.io/en/latest/troubleshooting.html#github-actions
uses: tlambert03/setup-qt-libs@v1
- name: Setup headless display
uses: pyvista/setup-headless-display-action@v2
- name: Install poetry
run: pipx install poetry==1.7.1
- name: Set up Python
Expand All @@ -62,6 +67,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install pyqtgraph dependencies
# https://pytest-qt.readthedocs.io/en/latest/troubleshooting.html#github-actions
uses: tlambert03/setup-qt-libs@v1
- name: Setup headless display
uses: pyvista/setup-headless-display-action@v2
- name: Install poetry
run: pipx install poetry==1.7.1
- name: Set up Python
Expand Down
3 changes: 3 additions & 0 deletions src/symmeplot/utilities/testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import os

ON_CI = os.getenv("CI", None) == "true"
6 changes: 3 additions & 3 deletions tests/core/test_core_plot_objects.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

import numpy as np
import pytest
import symmeplot.utilities.dummy_backend as dummy
import sympy as sm
import sympy.physics.mechanics as me
from symmeplot.utilities.testing import ON_CI

try:
import symmeplot.matplotlib as matplotlib
Expand All @@ -16,7 +16,7 @@

parametrize_backends = pytest.mark.parametrize(
"backend", [pytest.param(backend, marks=pytest.mark.skipif(
backend is None, reason="Backend not installed."))
backend is None and not ON_CI, reason="Backend not installed."))
for backend in (dummy, matplotlib, pyqtgraph)])


Expand Down Expand Up @@ -157,7 +157,7 @@ def test_scale(self, backend):
class TestPlotBodyMixin:
@pytest.fixture(autouse=True)
def _define_system(self, backend):
if backend is None:
if backend is None and not ON_CI:
pytest.skip("Backend not installed.")
self.q = sm.symbols("q")
self.N, self.O = me.ReferenceFrame("N"), me.Point("O")
Expand Down
7 changes: 4 additions & 3 deletions tests/core/test_core_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
import symmeplot.utilities.dummy_backend as dummy
import sympy.physics.mechanics as me
from symmeplot.utilities.testing import ON_CI

try:
import symmeplot.matplotlib as matplotlib
Expand All @@ -17,7 +18,7 @@

parametrize_backends = pytest.mark.parametrize(
"backend", [pytest.param(backend, marks=pytest.mark.skipif(
backend is None, reason="Backend not installed."))
backend is None and not ON_CI, reason="Backend not installed."))
for backend in (dummy, matplotlib, pyqtgraph)])

@pytest.fixture(scope="module", autouse=True)
Expand All @@ -29,7 +30,7 @@ def mock_visualization():
)
if pyqtgraph is not None:
to_patch.append(patch("pyqtgraph.exec"))
to_patch.append(patch("pyqtgraph.opengl.GLViewWidget.GLViewWidget.show"))
to_patch.append(patch("pyqtgraph.opengl.GLViewWidget.show"))
with contextlib.ExitStack() as stack:
for mgr in to_patch:
stack.enter_context(mgr)
Expand All @@ -38,7 +39,7 @@ def mock_visualization():
@parametrize_backends
class TestScene3D:
@pytest.fixture(autouse=True)
@pytest.mark.skipif("backend == None")
@pytest.mark.skipif("backend == None and not ON_CI")
def _define_system(self):
self.q = me.dynamicsymbols("q:3")
self.rf = me.ReferenceFrame("rf")
Expand Down
5 changes: 4 additions & 1 deletion tests/matplotlib/test_mpl_artists.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import numpy as np
import pytest
from symmeplot.utilities.testing import ON_CI

try:
from symmeplot.matplotlib.artists import Circle3D, Line3D, Vector3D
except ImportError:
except ImportError as e:
if ON_CI:
raise e
pytest.skip("Matplotlib not installed.", allow_module_level=True)


Expand Down
5 changes: 4 additions & 1 deletion tests/matplotlib/test_mpl_plot_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest
import sympy as sm
import sympy.physics.mechanics as me
from symmeplot.utilities.testing import ON_CI

try:
from symmeplot.matplotlib import (
Expand All @@ -11,7 +12,9 @@
PlotPoint,
PlotVector,
)
except ImportError:
except ImportError as e:
if ON_CI:
raise e
pytest.skip("Matplotlib not installed.", allow_module_level=True)


Expand Down
5 changes: 4 additions & 1 deletion tests/matplotlib/test_mpl_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import pytest
import sympy.physics.mechanics as me
from symmeplot.utilities.testing import ON_CI

try:
import matplotlib.pyplot as plt
from symmeplot.matplotlib import PlotFrame, Scene3D
except ImportError:
except ImportError as e:
if ON_CI:
raise e
pytest.skip("Matplotlib not installed.", allow_module_level=True)


Expand Down
5 changes: 4 additions & 1 deletion tests/pyqtgraph/test_pg_artists.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import numpy as np
import pytest
from symmeplot.utilities.testing import ON_CI

try:
from pyqtgraph.opengl import GLLinePlotItem, GLMeshItem, MeshData
Expand All @@ -11,7 +12,9 @@
Vector3D,
create_tube_mesh_data,
)
except ImportError:
except ImportError as e:
if ON_CI:
raise e
pytest.skip("PyQtGraph not installed.", allow_module_level=True)

class TestTubeMeshData:
Expand Down
Loading