test(py): add coverage for PyO3 bindings + gallery round-trip#43
Merged
Conversation
Grows the Python test suite from 5 tests (test_draw.py) to 27 across
two files:
tests/test_core.py
- top-level re-export smoke test (dkdc_draw → dkdc_draw.core)
- new_document structure
- save/load round-trip (empty + with element)
- SVG well-formedness
- PNG magic bytes, default scale, custom scale
- error paths: nonexistent load, invalid JSON on save/svg/png
tests/test_gallery_roundtrip.py
- Uses the 5 committed examples/gallery/*.draw.json fixtures
(flowchart, sticky, wireframe, sketch, patterns) to exercise
every element type and fill pattern against the Python layer.
- Per-slug: save-reload fixed point + SVG well-formed + PNG valid.
Deletes tests/test_draw.py — the 4 non-smoke tests were narrower
duplicates of the new test_core.py versions, and the `HAS_NATIVE`
ImportError guard was cargo-cult (the project ships via maturin and
every test needs the native module).
Run with `bin/test-py` or `uv run pytest`. Runs as part of `bin/test`.
Not added to `bin/check-py` to preserve the existing CI-skip pattern
(maturin+ty already local-only; tests follow suit).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lostmygithubaccount
added a commit
that referenced
this pull request
Apr 13, 2026
Bumps all Rust crates and the Python package from 0.2.1 to 0.3.0. This minor bump reflects one breaking change in the dkdc-draw-core public API surface (pub -> pub(crate) demotions in #42), accumulated with the non-breaking work from this cycle: - #35: arrow snap-to-shape connection points - #36: CONTRIBUTING.md + README badges - #37: integration tests for draw-core public API - #38: Rust + Python hello-world examples - #39: CHANGELOG.md scaffolding - #40: surgical clippy opt-ins workspace-wide - #41: sample gallery (5 drawings × json/svg/png) - #42: pub -> pub(crate) demotions (BREAKING) - #43: Python test coverage 5 -> 27 See CHANGELOG.md for the 0.3.0 section and migration notes for the demoted symbols. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Merged
4 tasks
lostmygithubaccount
added a commit
that referenced
this pull request
Apr 13, 2026
Bumps all Rust crates and the Python package from 0.2.1 to 0.3.0. This minor bump reflects one breaking change in the dkdc-draw-core public API surface (pub -> pub(crate) demotions in #42), accumulated with the non-breaking work from this cycle: - #35: arrow snap-to-shape connection points - #36: CONTRIBUTING.md + README badges - #37: integration tests for draw-core public API - #38: Rust + Python hello-world examples - #39: CHANGELOG.md scaffolding - #40: surgical clippy opt-ins workspace-wide - #41: sample gallery (5 drawings × json/svg/png) - #42: pub -> pub(crate) demotions (BREAKING) - #43: Python test coverage 5 -> 27 See CHANGELOG.md for the 0.3.0 section and migration notes for the demoted symbols. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Grows the Python test suite from 5 tests to 27. Covers the full
dkdc_draw.coresurface (new/save/load/export SVG/export PNG) plus error paths, and exercises every element type via the committedexamples/gallery/*.draw.jsonfixtures.Files
How to run
```bash
bin/test-py # or
uv run pytest # or
bin/test # runs bin/test-rs + bin/test-py
```
Scope notes
Not added to `bin/check-py`. The existing convention is that `check-py` skips maturin+ty in CI (because `draw-app` needs GTK); adding pytest would need maturin too, so it'd be skipped in CI for the same reason. Keeping pytest on the `bin/test-py` path preserves the existing split: `check` = lint/type, `test` = execute.
`run_cli` is not covered — it's argv-driven and structural correctness is already covered by the Rust tests.
Test plan
🤖 Generated with Claude Code