Closed as not planned
Description
I want to print the captured stdout, stderr and other loggers to different files for each individual test.
So I wrote a hook which changes log_file
for every test.
@pytest.hookimpl
def pytest_runtest_setup(item):
logging_plugin = item.config.pluginmanager.get_plugin("logging-plugin")
timestamp = datetime.strftime(datetime.now(), '%Y-%m-%d_%H-%M-%S')
logging_plugin.set_log_path(f'logs'/{item.name}_{timestamp}.log')
with a test that only raises an exception
def test_foobar():
raise Exception("foobar")
In pyproject.toml
I played around with various options for --capture=...
but it didn't matter
[tool.pytest.ini_options]
log_cli = true
all I get is an empty file.
I expected to see the exception and the full stack trace.
pytest==8.3.4
macOS Sonoma 14.5 (23F79)