Skip to content

Coverage testing #2158

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

Merged
merged 5 commits into from
Jun 16, 2025
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
34 changes: 34 additions & 0 deletions .github/workflows/save_coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Upload coverage

on:
workflow_run:
workflows: ['Code Tests', 'Geopandas tests', 'Code Tests with Latest branca', 'Selenium Tests', 'Run Snapshot Tests', 'Run Streamlit Folium Tests']
types: [completed]

jobs:
run:
runs-on: ubuntu-latest

steps:
- name: Download coverage files from previous steps
id: download-artifacts
uses: actions/download-artifact@v4
with:
path: combined-coverage
pattern: coverage-*
merge-multiple: true
token: ${{ secrets.GITHUB_TOKEN }}

- name: Combine coverage
run: coverage combine

- name: Generate report
run: coverage html --skip-covered

- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: combined-coverage
path: htmlcov/**
fail-on-empty: false
10 changes: 9 additions & 1 deletion .github/workflows/test_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,12 @@ jobs:
pip install pixelmatch

- name: Code tests
run: python -m pytest -vv --ignore=tests/selenium --ignore=tests/playwright --ignore=tests/snapshots
run: coverage run -p -m pytest -vv --ignore=tests/selenium --ignore=tests/playwright --ignore=tests/snapshots

- name: Upload coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-test-code
path: |
.coverage*
10 changes: 9 additions & 1 deletion .github/workflows/test_geopandas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@ jobs:
- name: Run Geopandas tests
run: |
cd geopandas
pytest -r a geopandas/tests/test_explore.py
coverage run -p -m pytest -r a geopandas/tests/test_explore.py

- name: Upload coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-test-geopandas
path: |
.coverage*
10 changes: 9 additions & 1 deletion .github/workflows/test_latest_branca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@ jobs:
run: |
micromamba remove branca --yes --force
python -m pip install git+https://github.com/python-visualization/branca.git
python -m pytest -vv --ignore=tests/selenium --ignore=tests/playwright --ignore=tests/snapshots
coverage run -p -m pytest -vv --ignore=tests/selenium --ignore=tests/playwright --ignore=tests/snapshots

- name: Upload coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-test-branca
path: |
.coverage*
10 changes: 9 additions & 1 deletion .github/workflows/test_selenium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,12 @@ jobs:

- name: Selenium tests
shell: bash -l {0}
run: python -m pytest tests/selenium -vv
run: coverage run -p -m pytest tests/selenium -vv

- name: Upload coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-test-selenium
path: |
.coverage*
10 changes: 9 additions & 1 deletion .github/workflows/test_snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Test with pytest
shell: bash -l {0}
run: |
python -m pytest tests/snapshots -s --junit-xml=test-results.xml
coverage run -p -m pytest tests/snapshots -s --junit-xml=test-results.xml

- name: Surface failing tests
if: always()
Expand All @@ -53,3 +53,11 @@ jobs:
path: |
/tmp/screenshot_*_*.png
/tmp/folium_map_*.html

- name: Upload coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-test-snapshots
path: |
.coverage*
13 changes: 11 additions & 2 deletions .github/workflows/test_streamlit_folium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
playwright install --with-deps

- name: Install annotate-failures-plugin
run: pip install pytest-github-actions-annotate-failures
run: pip install pytest-github-actions-annotate-failures coverage

- name: Install folium from source
shell: bash -l {0}
Expand All @@ -66,11 +66,20 @@ jobs:
shell: bash -l {0}
run: |
cd streamlit_folium
pytest tests/test_frontend.py --browser chromium -s --reruns 3 -k "not test_layer_control_dynamic_update" --junit-xml=test-results.xml
python -m pytest tests/test_frontend.py --browser chromium -s --reruns 3 -k "not test_layer_control_dynamic_update"

- name: Surface failing tests
if: always()
uses: pmeier/pytest-results-action@main
with:
path: streamlit_folium/test-results.xml
fail-on-empty: false


- name: Upload coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-test-streamlit-folium
path: |
.coverage*
7 changes: 5 additions & 2 deletions folium/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,16 @@

try:
from ._version import __version__
except ImportError:
except ImportError: # pragma: no cover
__version__ = "unknown"


if branca.__version__ != "unknown" and tuple(
int(x) for x in branca.__version__.split(".")[:2]
) < (0, 3):
) < (
0,
3,
): # pragma: no cover
raise ImportError(
"branca version 0.3.0 or higher is required. "
"Update branca with e.g. `pip install branca --upgrade`."
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/test_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_screenshot(path: str):
m.save(f"/tmp/folium_map_{path}.html")
assert mismatch < 200

else:
else: # pragma: no cover
shutil.copy(
f"/tmp/screenshot_new_{path}.png",
f"tests/snapshots/screenshots/screenshot_{path}.png",
Expand Down
Loading