Skip to content

Create example test file when adding pytest, with --no-example opt-out#1723

Merged
nathanjmcdougall merged 6 commits intomainfrom
copilot/add-dummy-test-file-for-pytest
Apr 1, 2026
Merged

Create example test file when adding pytest, with --no-example opt-out#1723
nathanjmcdougall merged 6 commits intomainfrom
copilot/add-dummy-test-file-for-pytest

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

Running pytest immediately after usethis tool pytest fails because the tests directory has no test files. This adds a tests/test_example.py with a trivial passing test so pytest works out of the box.

def test_add():
    """An example test - replace with your own tests!"""
    assert 1 + 1 == 2

Changes

  • _integrations/pytest/core.py — Added add_example_test() to create the example file; updated remove_pytest_dir() to treat test_example.py as a managed file (auto-cleaned on removal)
  • _core/tool.pyuse_pytest() accepts example: bool = True and calls add_example_test() when enabled
  • CLI layer — Added --example/--no-example option wired through usethis tool pytest and usethis test commands
  • _toolset/test.py — Threaded example param through use_test_frameworks()
  • Tests — Added TestAddExampleTest (content, message, idempotency), roundtrip/cleanup tests for remove_pytest_dir with example file, test_no_example at both core and CLI layers, plus test_conftest_already_exists for 100% module coverage
  • README.md — Updated example output

Copilot AI and others added 2 commits April 1, 2026 11:51
Copilot AI changed the title [WIP] Add dummy test file for pytest Create example test file when adding pytest, with --no-example opt-out Apr 1, 2026
Copilot AI requested a review from nathanjmcdougall April 1, 2026 11:55
@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review April 1, 2026 12:12
Copilot AI requested a review from nathanjmcdougall April 1, 2026 12:13
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 1, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing copilot/add-dummy-test-file-for-pytest (e487ddb) with main (c93a957)

Open in CodSpeed

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@nathanjmcdougall nathanjmcdougall merged commit bbd11fe into main Apr 1, 2026
20 checks passed
@nathanjmcdougall nathanjmcdougall deleted the copilot/add-dummy-test-file-for-pytest branch April 1, 2026 12:52
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.

Consider creating a dummy test file for pytest

2 participants