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 django should redirect settings.MEDIA_ROOT automatically so that the state isn't shared between tests in the form of media.
For compatibility with pytest-xdist, maybe each test run can have it's own folder, so that folders can get deleted without other tests running at the same time being effected (note: this would be io heavy)
The text was updated successfully, but these errors were encountered:
@pytest.fixture(autouse=True)# the other fixtures come from pytest-xdist# if not using that plugin just hash the current testdefmedia_setup(settings, worker_id: str, testrun_uid: str):
# setupsettings.MEDIA_ROOT= (
Path(settings.BASE_DIR) /"test-media"/f"media-{worker_id}-{testrun_uid}"
)
# make sure no old/manual stuff added affects testsifsettings.MEDIA_ROOT.exists():
shutil.rmtree(settings.MEDIA_ROOT)
settings.MEDIA_ROOT.mkdir(parents=True)
yield# cleanup the media so it doesn't cause# problems elsewhereifsettings.MEDIA_ROOT.exists():
shutil.rmtree(settings.MEDIA_ROOT)
Pytest django should redirect
settings.MEDIA_ROOT
automatically so that the state isn't shared between tests in the form of media.For compatibility with pytest-xdist, maybe each test run can have it's own folder, so that folders can get deleted without other tests running at the same time being effected (note: this would be io heavy)
The text was updated successfully, but these errors were encountered: