Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add test files cleanup
Paweł Zarębski82c6a77d02c5
diff --git a/tests/conftest.py b/tests/conftest.pyindex 06cc82ff8b..50dcb85c97 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -1,7 +1,9 @@from io import BytesIO+from shutil import rmtreefrom unittest.mock import MagicMock, Mockimport pytest+from django.conf import settings as django_settingsfrom django.contrib.auth.models import Permissionfrom django.contrib.sites.models import Sitefrom django.core.files import File@@ -40,6 +42,18 @@ from saleor.site import AuthenticationBackendsfrom saleor.site.models import AuthorizationKey, SiteSettings+def pytest_configure(config):+ """ Remove test files which may have stayed after running tests before. """++ rmtree(django_settings.MEDIA_ROOT, ignore_errors=True)+++def pytest_unconfigure(config):+ """ Remove test files after running all tests. """++ rmtree(django_settings.MEDIA_ROOT, ignore_errors=True)++@pytest.fixture(autouse=True)def site_settings(db, settings):"""Create a site and matching site settings.diff --git a/tests/settings.py b/tests/settings.pyindex 105aff1d88..e95956f7de 100644--- a/tests/settings.py+++ b/tests/settings.py@@ -32,3 +32,5 @@ CHECKOUT_PAYMENT_GATEWAYS = {}COUNTRIES_ONLY = None++MEDIA_ROOT = os.path.join(MEDIA_ROOT, 'test')