Skip to content

fix(template): stop shipping a stray example test and a broken newline - #183

Merged
gtauzin merged 1 commit into
mainfrom
fix/test-examples-template-bugs
Jul 17, 2026
Merged

gtauzin merged 1 commit into
mainfrom
fix/test-examples-template-bugs

Conversation

@gtauzin

@gtauzin gtauzin commented Jul 17, 2026

Copy link
Copy Markdown
Member

Description

Two defects in the example-notebook test, both surfaced by the v0.27.0 fleet fan-out and both fixes bundled here for a v0.27.1 patch. They live in the two near-duplicate .jinja sources that render to tests/test_examples.py.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Motivation and Context

Stray 1-byte test file. template/tests/ shipped two near-duplicate sources for the example test — one filename-gated ({% if include_examples %}test_examples.py{% endif %}.jinja) and one ungated (test_examples.py.jinja). Both render to tests/test_examples.py when examples are on (one silently overwrites the other), and with include_examples=false the ungated twin renders a stray 1-byte tests/test_examples.py. It broke nothing — an empty file collects no tests — which is exactly why it hid for releases. Fix: delete the ungated source; the filename-gated one correctly produces no file when examples are off (verified).

Literal \n in the failure message. The assert-failure f-string used a doubled backslash (failed with:\\nSTDOUT:), so a notebook-failure diagnostic printed a literal \n as text instead of breaking lines. Fix: single backslash. Proven: the rendered message now spans 5 lines (4 real newlines) instead of 1.

Both were found during the fan-out — the second by sklearn-wrap's update agent, which had carried the correct \n since its initial commit and would otherwise have silently re-rejected the template's regression on every future update.

How Has This Been Tested?

  • Tested locally with uv run pytest — 324 passed
  • Tested template generation with copier copy . /tmp/test-project — both include_examples values
  • Verified generated project works as expected
  • Added/updated tests
  • All tests pass

Verified, not assumed:

  • include_examples=false → no tests/test_examples.py at all (was: stray 1-byte file).
  • include_examples=true → the test renders with a real newline escape; evaluating the f-string yields a 5-line message.
  • New assertions falsified: the newline check returns False on the old doubled-backslash content and True on the fixed content, so it genuinely bites.

Checklist

  • My code follows the code style of this project
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • My changes generate no new warnings
  • I have checked that my changes don't break the template generation

Additional Notes

Fleet impact is benign. No generated repo receives a regression from this: repos that already carry the doubled-backslash form are unchanged, and sklearn-wrap already carries the correct \n (its fan-out agent preserved it). After this ships, sklearn-wrap's local delta disappears on its next update. The stray-file fix only affects the two include_examples=false repos (kedro-dagster, kedro-azureml-pipeline), neither of which currently carries the stray file.

Out of scope, flagged for later: sklearn-wrap's fan-out also noted that nox -s lint and the justfile lint: recipe run ty check src without --extra <name>, so a project needing an optional extra for ty must add it in more than one place. That's a template-consistency question, not a clear bug, and is left for a separate change.

🤖 Generated with Claude Code

Two defects in the example-notebook test, both surfaced by the v0.27.0 fleet
fan-out and both living in the two near-duplicate .jinja sources that rendered
to tests/test_examples.py.

The filename-gated source and an ungated twin both rendered the file; with
include_examples=false the ungated one left a stray 1-byte tests/test_examples.py
that broke nothing and so hid for releases. Delete it and keep only the
filename-gated source, which correctly produces no file when examples are off.

The assert-failure f-string used a doubled backslash, so the diagnostic printed a
literal \n instead of breaking lines. Use a single backslash.

Tests now assert no test_examples.py exists when examples are disabled, and that
the failure message keeps a real newline escape.
@gtauzin
gtauzin merged commit 0ab6038 into main Jul 17, 2026
14 checks passed
@gtauzin
gtauzin deleted the fix/test-examples-template-bugs branch July 17, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant