From a54ef1cfdfd3da87fbfd94240b915ef6de354ac7 Mon Sep 17 00:00:00 2001 From: Nathan McDougall Date: Wed, 9 Jul 2025 07:52:20 +1200 Subject: [PATCH 1/2] Include Coverage.py as a default recommended test framework tool as a part of `usethis test` Also fix a typo in the test suite --- src/usethis/_toolset/test.py | 3 ++- tests/usethis/_integrations/uv/test_init.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/usethis/_toolset/test.py b/src/usethis/_toolset/test.py index 13dff4b3..eda670c6 100644 --- a/src/usethis/_toolset/test.py +++ b/src/usethis/_toolset/test.py @@ -1,5 +1,6 @@ -from usethis._core.tool import use_pytest +from usethis._core.tool import use_coverage_py, use_pytest def use_test_frameworks(remove: bool = False, how: bool = False): use_pytest(remove=remove, how=how) + use_coverage_py(remove=remove, how=how) diff --git a/tests/usethis/_integrations/uv/test_init.py b/tests/usethis/_integrations/uv/test_init.py index 7928937f..e037a32a 100644 --- a/tests/usethis/_integrations/uv/test_init.py +++ b/tests/usethis/_integrations/uv/test_init.py @@ -11,7 +11,7 @@ from usethis._test import change_cwd -class TestTestOpinionatedUVInit: +class TestOpinionatedUVInit: def test_empty_dir(self, tmp_path: Path): # Act with change_cwd(tmp_path): From 428ab1d98728cd9a504aa83781daed4d84464bd0 Mon Sep 17 00:00:00 2001 From: Nathan McDougall Date: Fri, 11 Jul 2025 09:08:49 +1200 Subject: [PATCH 2/2] Update tests and README to reflect new behaviour --- README.md | 1 + tests/usethis/_interface/test_init.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index 3edcad3e..d19a0ed9 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ $ uvx usethis init ☐ Add test files to the '/tests' directory with the format 'test_*.py'. ☐ Add test functions with the format 'test_*()'. ☐ Run 'uv run pytest' to run the tests. +☐ Run 'uv run pytest --cov' to run your tests with Coverage.py. ``` To use Ruff on an existing project, run: diff --git a/tests/usethis/_interface/test_init.py b/tests/usethis/_interface/test_init.py index c6ef09ba..b70e894d 100644 --- a/tests/usethis/_interface/test_init.py +++ b/tests/usethis/_interface/test_init.py @@ -39,6 +39,7 @@ def test_pre_commit_included(self, tmp_path: Path): "☐ Add test files to the '/tests' directory with the format 'test_*.py'.\n" "☐ Add test functions with the format 'test_*()'.\n" "☐ Run 'uv run pytest' to run the tests.\n" + "☐ Run 'uv run pytest --cov' to run your tests with Coverage.py.\n" ) # Check the pre-commit hooks are added in the correct order @@ -87,6 +88,7 @@ def test_readme_example(self, tmp_path: Path): ☐ Add test files to the '/tests' directory with the format 'test_*.py'. ☐ Add test functions with the format 'test_*()'. ☐ Run 'uv run pytest' to run the tests. +☐ Run 'uv run pytest --cov' to run your tests with Coverage.py. """ ) @@ -156,6 +158,7 @@ def test_bitbucket_docstyle_and_status(self, tmp_path: Path): "☐ Add test files to the '/tests' directory with the format 'test_*.py'.\n" "☐ Add test functions with the format 'test_*()'.\n" "☐ Run 'uv run pytest' to run the tests.\n" + "☐ Run 'uv run pytest --cov' to run your tests with Coverage.py.\n" "✔ Adding Bitbucket Pipelines configuration.\n" "☐ Run your pipeline via the Bitbucket website.\n" )