Regression Tests
This project uses golden-file regression tests to ensure the geometry emitted by rmfiles.RemarkableNotebook stays stable over time.
Fixtures live in
fixtures/*.rmand represent known-good.rmpages.Tests regenerate shapes using the public API, then canonicalize both the new output and the fixture for a stable comparison.
Canonicalization reduces each line to
(tool_id, color_id, [(x, y), ...])with points rounded to 4 decimals to avoid floating-point noise.
Where to look
Primitive shape regression tests:
tests/test_regression_primitives.pyPath (Bezier) regression test:
tests/test_regression_paths.pyFixtures:
fixtures/
Running tests
make venv
source .venv/bin/activate
pytest -q
Dependency note:
The regression tests require the
rmscenepackage. Ifrmsceneis not installed, the test suite fails during collection. Install all dependencies first using the commands above.
Updating fixtures
Only update fixtures when a deliberate, vetted change modifies the intended geometry. Steps:
Recreate the output using the test’s parameters and write to a temp file (e.g., by locally adjusting the test to write next to the fixture or by running an example script like
examples/primitives_demo.py).Inspect the difference by opening both
.rmfiles in a viewer and/or by using the canonical diff helpers from tests.If the change is intentional, replace the corresponding file in
fixtures/and commit with a clear message (include rationale in the PR).
Guidelines:
Do not update fixtures to paper over bugs; fix the code instead.
Keep the scene tool and color consistent across fixture and test (tests usually rely on defaults or explicitly set a preset/tool for determinism).
This project standardizes on a stroke width of 24 for regression fixtures to keep shapes visually clear and to avoid ambiguity. The regeneration script and example code use
width=24accordingly.
Regenerating all fixtures
Use the helper script to regenerate the exact fixtures used by tests:
make fixtures-rebuild
This runs scripts/regenerate_regression_fixtures.py and writes the golden .rm files into fixtures/.
Standard sample constants
Import
rmfiles.testingwhen generating sample.rmcontent to ensure consistent, deterministic fixtures and examples:
from rmfiles.testing import SAMPLE_LINE_WIDTH, SAMPLE_TOOL
These are used by tests, examples, and the fixture regeneration script.
Test helpers
If you write a helper used by multiple tests (e.g., canonical diffing, point rounding, common scene builders), add it to
rmfiles.testingso tests, examples, and fixture tools can share a single implementation.Treat
rmfiles.testingas the central place for generalized testing utilities and sample defaults.
Adding a new regression test
Create a fixture: generate the
.rmyou expect via the public API and save it underfixtures/<name>_fixture.rm.Write a test in
tests/that regenerates the same content and compares canonicalized lines from the new file vs. the fixture.Keep inputs explicit (e.g., set
deg=True, sample counts, and tool/preset when relevant) to avoid accidental changes.