Skip to content

Commit

Permalink
Fix matplotlib and cartopy tests (#49)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
ryanking13 and pre-commit-ci[bot] authored Aug 12, 2024
1 parent c90f23c commit fc9a223
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ jobs:
--dist-dir=./dist/ \
--runner=${{ matrix.test-config.runner }} \
--rt ${{ matrix.test-config.runtime }} \
-k "not triangulation and not cartopy" \
packages
release:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions packages/Cartopy/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ requirements:
- matplotlib
- scipy


build:
vendor-sharedlib: true
script: |
Expand Down
34 changes: 21 additions & 13 deletions packages/Cartopy/test_cartopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import pytest
from pytest_pyodide import run_in_pyodide

from conftest import package_is_built

DECORATORS = [
pytest.mark.xfail_browsers(node="No supported matplotlib backends on node"),
pytest.mark.skip_refcount_check,
Expand All @@ -25,22 +27,28 @@ def test_imports(selenium):


@matplotlib_test_decorator
@run_in_pyodide(packages=["Cartopy", "matplotlib", "pyodide-http"])
def test_matplotlib(selenium):
import io
if not package_is_built("pyodide-http"):
pytest.skip("pyodide-http is not built")

@run_in_pyodide(packages=["Cartopy", "matplotlib", "pyodide-http"])
def run(selenium):
import io

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import pyodide_http

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import pyodide_http
pyodide_http.patch_all()

pyodide_http.patch_all()
ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines()

ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines()
fd = io.BytesIO()
plt.savefig(fd, format="svg")

fd = io.BytesIO()
plt.savefig(fd, format="svg")
content = fd.getvalue().decode("utf8")
assert len(content) > 100000
assert content.startswith("<?xml")

content = fd.getvalue().decode("utf8")
assert len(content) > 100000
assert content.startswith("<?xml")
run(selenium)
1 change: 1 addition & 0 deletions packages/matplotlib/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ source:
- - extras/setup.cfg
- ./mplsetup.cfg


build:
# RELOCATABLE flag is required because if affects how emscripten build ports.
cflags: |
Expand Down

0 comments on commit fc9a223

Please sign in to comment.