Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/history/hatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## Unreleased

***Fixed***

***Fixed:***

- Erase stale coverage data before running `hatch test --cover`.

- Fix environment creation crashing when a metadata hook exists that doesn’t happen to be installed in the `hatch` CLI’s environment.


## [1.17.1](https://github.com/pypa/hatch/releases/tag/hatch-v1.17.1) - 2026-07-08 ## {: #hatch-v1.17.1 }

***Fixed***
Expand Down
4 changes: 4 additions & 0 deletions src/hatch/cli/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ def test(
if cover:
patched_coverage.write_config_file()

for context in app.runner_context([selected_envs[0]]):
context.add_shell_command("coverage erase")
context.env_vars["COVERAGE_RCFILE"] = coverage_config_file

for context in app.runner_context(selected_envs, ignore_compat=multiple_possible, display_header=multiple_possible):
internal_arguments: list[str] = list(context.env.config.get("extra-args", []))

Expand Down
6 changes: 6 additions & 0 deletions tests/cli/test/test_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def test_flag(self, hatch, temp_dir, config_file, env_run, mocker):
assert not result.output

assert env_run.call_args_list == [
mocker.call("coverage erase", shell=True),
mocker.call("coverage run -m pytest -p no:randomly tests", shell=True),
mocker.call("coverage combine", shell=True),
mocker.call("coverage report", shell=True),
Expand Down Expand Up @@ -230,6 +231,7 @@ def test_flag_with_arguments(self, hatch, temp_dir, config_file, env_run, mocker
assert not result.output

assert env_run.call_args_list == [
mocker.call("coverage erase", shell=True),
mocker.call("coverage run -m pytest -p no:randomly --flag -- arg1 arg2", shell=True),
mocker.call("coverage combine", shell=True),
mocker.call("coverage report", shell=True),
Expand Down Expand Up @@ -266,6 +268,7 @@ def test_quiet_implicitly_enables(self, hatch, temp_dir, config_file, env_run, m
assert not result.output

assert env_run.call_args_list == [
mocker.call("coverage erase", shell=True),
mocker.call("coverage run -m pytest -p no:randomly tests", shell=True),
mocker.call("coverage combine", shell=True),
]
Expand Down Expand Up @@ -303,6 +306,7 @@ def test_legacy_config_define_section(self, hatch, temp_dir, config_file, env_ru
assert not result.output

assert env_run.call_args_list == [
mocker.call("coverage erase", shell=True),
mocker.call("coverage run -m pytest -p no:randomly tests", shell=True),
mocker.call("coverage combine", shell=True),
mocker.call("coverage report", shell=True),
Expand Down Expand Up @@ -341,6 +345,7 @@ def test_legacy_config_enable_parallel(self, hatch, temp_dir, config_file, env_r
assert not result.output

assert env_run.call_args_list == [
mocker.call("coverage erase", shell=True),
mocker.call("coverage run -m pytest -p no:randomly tests", shell=True),
mocker.call("coverage combine", shell=True),
mocker.call("coverage report", shell=True),
Expand Down Expand Up @@ -809,6 +814,7 @@ def test_coverage(self, hatch, temp_dir, config_file, env_run, mocker):
assert not result.output

assert env_run.call_args_list == [
mocker.call("coverage erase", shell=True),
mocker.call("test with coverage", shell=True),
mocker.call("combine coverage", shell=True),
mocker.call("show coverage", shell=True),
Expand Down
Loading