You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@pytest.fixture(scope="session", autouse=True)defdelete_output_dir(pytestconfig: Any) ->None:
output_dir=pytestconfig.getoption("--output")
ifos.path.exists(output_dir):
try:
shutil.rmtree(output_dir)
except (FileNotFoundError, PermissionError):
# When running in parallel, another thread may have already deleted the filespassexceptOSErroraserror:
iferror.errno!=16:
raise# We failed to remove folder, might be due to the whole folder being mounted inside a container:# https://github.com/microsoft/playwright/issues/12106# https://github.com/microsoft/playwright-python/issues/1781# Do a best-effort to remove all files inside of it instead.entries=os.listdir(output_dir)
forentryinentries:
shutil.rmtree(entry)
Fixtures in pytest are not executed at the start of the pytest "lifecycle", but only before the actual test-run.
This can results in an un-wanted deletion of the "test-results" folder.
why delete the folder at the first place, and not delete the plugin generated data only?
Can we maybe (by default) create a "pytest-playwright" folder inside the "test-results", and delete only that? (to not affect other uses of the "test-results" folder)
Can we move the folder deletion part to an earlier stage, using pytest hooks for example?
Fixtures are meant to prepare the environment for the test execution, and the deletion of the folder is not really preparing the tests, and in a stage this late it can (in my case already did :'} ) have unintended effects.
let me know what you think, im open to implementing something and creating a PR :)
The text was updated successfully, but these errors were encountered:
arieluchka-bse
changed the title
deleting "test-results" folder by default
deleting "test-results" folder early on by default
Jan 2, 2025
Hola :)
have noticed that the pytest-playwright uses "test-results" folder by default, and that there is a session scoped fixture that deletes it.
Fixtures in pytest are not executed at the start of the pytest "lifecycle", but only before the actual test-run.
This can results in an un-wanted deletion of the "test-results" folder.
why delete the folder at the first place, and not delete the plugin generated data only?
Can we maybe (by default) create a "pytest-playwright" folder inside the "test-results", and delete only that? (to not affect other uses of the "test-results" folder)
Can we move the folder deletion part to an earlier stage, using pytest hooks for example?
here are some candidates:
more on pytest_sessionstart
Fixtures are meant to prepare the environment for the test execution, and the deletion of the folder is not really preparing the tests, and in a stage this late it can (in my case already did :'} ) have unintended effects.
let me know what you think, im open to implementing something and creating a PR :)
The text was updated successfully, but these errors were encountered: