Skip to content

fix(scaffold): ship placeholder pytest file so first commit succeeds (DOT-491)#308

Merged
ichoosetoaccept merged 1 commit intomainfrom
ismart/dot-491-placeholder-test
Apr 16, 2026
Merged

fix(scaffold): ship placeholder pytest file so first commit succeeds (DOT-491)#308
ichoosetoaccept merged 1 commit intomainfrom
ismart/dot-491-placeholder-test

Conversation

@ichoosetoaccept
Copy link
Copy Markdown
Member

@ichoosetoaccept ichoosetoaccept commented Apr 16, 2026

Closes DOT-491

Summary

  • Add project/tests/__init__.py and project/tests/test_{{python_package_import_name}}.py.jinja — a one-line smoke test that imports the package.
  • Add the placeholder test file to _skip_if_exists in copier.yml so copier update never overwrites real tests once the user has written them.
  • Update unit tests: rename test_tests_directory_not_generatedtest_tests_directory_has_placeholder and adjust test_app_type_no_scaffold_code to allow the placeholder.

Why

pytest-testmon exits with code 5 when no tests are collected, which broke the very first commit on every freshly scaffolded project. Shipping a single passing test gets pytest to exit 0; the user replaces it as soon as they write real tests.

Test plan

@linear
Copy link
Copy Markdown

linear Bot commented Apr 16, 2026

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 16, 2026

Greptile Summary

This PR ships a placeholder pytest smoke test (test_{{python_package_import_name}}.py.jinja) and an empty tests/__init__.py so that pytest-testmon exits 0 (instead of code 5 for "no tests collected") on the first commit of every freshly scaffolded project. Both files are added to _skip_if_exists so copier update never overwrites real tests once the user has written them. The unit tests are updated to verify the placeholder is present for both app and lib project types.

Confidence Score: 5/5

Safe to merge — focused fix with no logic issues, correct _skip_if_exists usage, and positive test coverage for both project types.

All findings are P2 or lower. The template syntax follows the established pattern, the _skip_if_exists entries are correct, the empty __init__.py is intentional, and the updated tests verify the new behavior for both app and lib project types.

No files require special attention.

Important Files Changed

Filename Overview
copier.yml Adds tests/__init__.py and tests/test_{{ python_package_import_name }}.py to _skip_if_exists, following the established pattern used for src/{{ python_package_import_name }}/__init__.py.
project/tests/init.py Empty package marker file — correct and intentional.
project/tests/test_{{python_package_import_name}}.py.jinja New Jinja template generating a one-assertion smoke test; uses project_name and python_package_import_name correctly, no conditional blocks, renders valid Python for any valid slug.
tests/test_template.py Renames the old "not generated" assertion to a positive placeholder check, loops over both project types, and removes the now-invalid __init__.py absence assertion from test_app_type_no_scaffold_code.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[copier copy / copier update] --> B{File exists in destination?}
    B -- No --> C[Generate tests/__init__.py\nand test_pkg.py from template]
    B -- Yes --> D[Skip — _skip_if_exists\npreserves user's real tests]
    C --> E[First commit:\npytest-testmon collects test → exit 0 ✓]
    D --> F[copier update safe:\nuser's tests untouched]
Loading

Reviews (3): Last reviewed commit: "fix(scaffold): ship placeholder pytest f..." | Re-trigger Greptile

@ichoosetoaccept ichoosetoaccept force-pushed the ismart/dot-492-lychee-cooldown-on-second-autoupdate-pass branch from 75952da to a6387c4 Compare April 16, 2026 20:34
@ichoosetoaccept ichoosetoaccept force-pushed the ismart/dot-491-placeholder-test branch from 4785460 to 4c241cf Compare April 16, 2026 20:35
Base automatically changed from ismart/dot-492-lychee-cooldown-on-second-autoupdate-pass to main April 16, 2026 20:51
@ichoosetoaccept ichoosetoaccept force-pushed the ismart/dot-491-placeholder-test branch from 4c241cf to 77fb7b7 Compare April 16, 2026 21:24
@ichoosetoaccept ichoosetoaccept force-pushed the ismart/dot-491-placeholder-test branch from 77fb7b7 to 5ab22c6 Compare April 16, 2026 21:26
@ichoosetoaccept ichoosetoaccept merged commit 679aa1c into main Apr 16, 2026
6 checks passed
@ichoosetoaccept ichoosetoaccept deleted the ismart/dot-491-placeholder-test branch April 16, 2026 21:44
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