mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
List dir when test fails (#33685)
This commit is contained in:
@@ -52,7 +52,7 @@ def mock_init_cache_dir():
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def empty_cache_dir(tmp_path, mock_init_cache_dir, mock_get_cache_files):
|
||||
def empty_cache_dir(tmp_path, mock_init_cache_dir, mock_get_cache_files, request):
|
||||
"""Mock the TTS cache dir with empty dir."""
|
||||
mock_init_cache_dir.side_effect = None
|
||||
mock_init_cache_dir.return_value = str(tmp_path)
|
||||
@@ -60,7 +60,18 @@ def empty_cache_dir(tmp_path, mock_init_cache_dir, mock_get_cache_files):
|
||||
# Restore original get cache files behavior, we're working with a real dir.
|
||||
mock_get_cache_files.side_effect = _get_cache_files
|
||||
|
||||
return tmp_path
|
||||
yield tmp_path
|
||||
|
||||
if request.node.rep_call.passed:
|
||||
return
|
||||
|
||||
# Print contents of dir if failed
|
||||
print("Content of dir for", request.node.nodeid)
|
||||
for fil in tmp_path.iterdir():
|
||||
print(fil.relative_to(tmp_path))
|
||||
|
||||
# To show the log.
|
||||
assert False
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
||||
Reference in New Issue
Block a user