Refactor Tests#11
Conversation
…unit tests for state-push functionality
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11 +/- ##
=======================================
Coverage 77.61% 77.61%
=======================================
Files 12 12
Lines 2319 2319
=======================================
Hits 1800 1800
Misses 519 519 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR refactors and reorganizes the test suite by moving tests under anyplotlib/tests, consolidating coverage areas into more structured modules (layouts/interactive/documentation/benchmarks/plots), and adding/relocating baseline assets to support visual regression testing.
Changes:
- Move/merge legacy
tests/modules into a package-scoped test tree (anyplotlib/tests/...) and update pytest discovery to match. - Add new structured test modules for Plot3D, markers, documentation bridge/scraper/push-hook, and pure-Python benchmarks.
- Introduce/relocate PNG baseline assets and PNG encode/decode utilities for visual regression testing.
Reviewed changes
Copilot reviewed 26 out of 62 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_scraper.py | Removed legacy scraper thumbnail tests (moved under anyplotlib/tests/test_documentation/). |
| tests/test_plotbar_extras.py | Removed legacy PlotBar extras tests (coverage appears redistributed across new test structure). |
| tests/test_plot2d_polish.py | Removed legacy Plot2D polish/regression tests (parts moved into test_plot2d_api.py). |
| tests/test_plot1d_linestyle.py | Removed legacy Plot1D linestyle tests (coverage appears redistributed). |
| tests/test_plot1d_extras.py | Removed legacy Plot1D extras tests (coverage appears redistributed). |
| tests/test_panel_alignment.py | Removed legacy panel alignment tests (merged into test_gridspec.py). |
| tests/test_inset_visual.py | Removed legacy inset visual regression tests (merged into test_layouts/test_inset.py). |
| tests/test_imshow_params.py | Removed legacy imshow parameter tests (coverage appears redistributed). |
| tests/test_imshow_extras.py | Removed legacy Plot2D extras tests (coverage appears redistributed). |
| pyproject.toml | Update pytest discovery path to anyplotlib/tests (requires follow-up for coverage/packaging implications). |
| anyplotlib/tests/test_plot3d/test_plot3d.py | Added Plot3D construction/mutation/validation tests. |
| anyplotlib/tests/test_plot3d/init.py | Added package init for Plot3D test subpackage. |
| anyplotlib/tests/test_plot2d/test_plot2d_api.py | Added cross-cutting Plot* repr/API regression tests. |
| anyplotlib/tests/test_plot2d/test_pcolormesh.py | Expanded/refined PlotMesh test coverage and reorganized file location. |
| anyplotlib/tests/test_plot2d/init.py | Added package init for Plot2D test subpackage. |
| anyplotlib/tests/test_plot1d/init.py | Added package init for Plot1D test subpackage. |
| anyplotlib/tests/test_markers/test_markers.py | Added comprehensive marker system + helper API tests. |
| anyplotlib/tests/test_markers/init.py | Added package init for markers test subpackage. |
| anyplotlib/tests/test_layouts/test_visual.py | Updated visual regression tests; currently uses a baseline path that doesn’t match where baselines were added. |
| anyplotlib/tests/test_layouts/test_inset.py | Added inset visual regression section; currently uses a baseline path that doesn’t match where baselines were added. |
| anyplotlib/tests/test_layouts/test_gridspec.py | Extended GridSpec tests with panel alignment checks and PAD-constant documentation. |
| anyplotlib/tests/test_layouts/init.py | Added package init for layouts test subpackage. |
| anyplotlib/tests/test_interactive/test_widgets.py | Updated interactive widget tests and documentation within docstring. |
| anyplotlib/tests/test_interactive/test_callbacks.py | Reorganized callback tests; refocused a section on Figure event routing. |
| anyplotlib/tests/test_interactive/init.py | Added package init for interactive test subpackage. |
| anyplotlib/tests/test_documentation/test_sphinx_anywidget.py | Added sphinx_anywidget smoke tests for directive/scraper/utils. |
| anyplotlib/tests/test_documentation/test_scraper.py | Added scraper thumbnail tests; currently skips the whole module when Playwright is missing (blocking non-Playwright checks). |
| anyplotlib/tests/test_documentation/test_push_hook.py | Added unit tests for _push()/_push_layout() traitlet state propagation. |
| anyplotlib/tests/test_documentation/test_bridge.py | Added Playwright E2E tests for iframe messaging and full mock Pyodide boot bridge. |
| anyplotlib/tests/test_documentation/init.py | Added package init for documentation test subpackage. |
| anyplotlib/tests/test_benchmarks/test_benchmarks.py | Updated benchmark test imports to match new test package layout. |
| anyplotlib/tests/test_benchmarks/test_benchmarks_py.py | Added pure-Python serialization performance benchmarks + baseline comparison. |
| anyplotlib/tests/test_benchmarks/baselines.json | Added benchmark baseline data/metadata. |
| anyplotlib/tests/test_benchmarks/init.py | Added package init for benchmarks test subpackage. |
| anyplotlib/tests/conftest.py | Updated shared fixtures/util imports for new test package layout. |
| anyplotlib/tests/baselines/imshow_gradient.png | Added/relocated baseline PNG for visual regression. |
| anyplotlib/tests/baselines/imshow_checkerboard.png | Added/relocated baseline PNG for visual regression. |
| anyplotlib/tests/baselines/bar_basic.png | Added/relocated baseline PNG for visual regression. |
| anyplotlib/tests/_png_utils.py | Added PNG encode/decode + image diff utilities (minor cleanup needed). |
| anyplotlib/tests/init.py | Added package init for the test package. |
Comments suppressed due to low confidence (3)
pyproject.toml:55
- Since tests were moved under
anyplotlib/tests, the coverage config now treats them as in-scope code (source = ["anyplotlib"]) butomit = ["tests/*", ...]no longer matches. This will skew coverage (and may fail CI) unless you also omitanyplotlib/tests/*(and likelyanyplotlib/tests/baselines/*). Separately,hatchwill now packageanyplotlib/testsinto the wheel viapackages = ["anyplotlib"]; if that’s not intended, add an explicit exclude to avoid shipping large baseline PNGs.
anyplotlib/tests/test_layouts/test_visual.py:42 BASELINESpoints toanyplotlib/tests/test_layouts/baselines, but the baseline PNGs added in this PR live underanyplotlib/tests/baselines. As written, these visual regression tests will always hit theif not path.exists(): pytest.skip(...)path and won’t validate rendering in CI. Update the baseline directory (or move the PNGs) so the tests actually exercise the golden images.
anyplotlib/tests/test_layouts/test_inset.py:282BASELINESpoints toanyplotlib/tests/test_layouts/baselines, but the inset baseline PNGs in this PR are underanyplotlib/tests/baselines. With the current path, all visual inset checks will be skipped due to missing baselines. PointBASELINESat the shared baselines directory (or relocate the PNGs) so these regression tests run.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # ───────────────────────────────────────────────────────────────────────────── | ||
| # Section 2 — Dark-theme pixel validation (requires Playwright) | ||
| # ───────────────────────────────────────────────────────────────────────────── | ||
|
|
||
| pytest.importorskip("playwright", reason="playwright not installed") | ||
|
|
||
|
|
||
| class TestThumbnailDarkTheme: | ||
| """Verify the top-left pixel of each thumbnail is dark-blue, matching the |
Refactoring tests, renaming and organizing tests as well as merging tests into like files. Better handling for tests etc.