[core] Improve clean-all with no arguments (#15184)

This commit is contained in:
Jonathan Swoboda
2026-03-26 13:39:19 -04:00
committed by GitHub
parent 02e23eb386
commit c2456409bd
2 changed files with 51 additions and 0 deletions
+41
View File
@@ -990,6 +990,47 @@ def test_clean_all_ignores_empty_env_vars(
assert marker.exists()
@patch("esphome.writer.CORE")
def test_clean_all_no_args_with_esphome_dir(
mock_core: MagicMock,
tmp_path: Path,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test clean_all with no args cleans .esphome in cwd."""
esphome_dir = tmp_path / ".esphome"
esphome_dir.mkdir()
(esphome_dir / "dummy.txt").write_text("x")
from esphome.writer import clean_all
with (
caplog.at_level("INFO"),
patch("esphome.writer.Path.cwd", return_value=tmp_path),
):
clean_all([])
assert esphome_dir.exists()
assert not (esphome_dir / "dummy.txt").exists()
@patch("esphome.writer.CORE")
def test_clean_all_no_args_no_esphome_dir(
mock_core: MagicMock,
tmp_path: Path,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test clean_all with no args and no .esphome dir warns."""
from esphome.writer import clean_all
with (
caplog.at_level("WARNING"),
patch("esphome.writer.Path.cwd", return_value=tmp_path),
):
clean_all([])
assert "No configuration files specified" in caplog.text
@patch("esphome.writer.CORE")
def test_clean_all(
mock_core: MagicMock,