List dir when test fails (#33685)

This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2020-04-05 12:15:29 +02:00
1 parent 24840b54ac
commit 5bf7e0fcc0
2 files changed
+31 -2

No files matched your search

+13 -2
View File
@@ -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)