diff --git a/openslides/core/apps.py b/openslides/core/apps.py index 413ac7a67..3c56b60d9 100644 --- a/openslides/core/apps.py +++ b/openslides/core/apps.py @@ -6,6 +6,7 @@ from django.apps import AppConfig from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.db.models.signals import post_migrate +from django.db.utils import OperationalError from ..utils.projector import register_projector_elements @@ -43,8 +44,8 @@ class CoreAppConfig(AppConfig): # Set constants try: set_constants(get_constants_from_apps()) - except ImproperlyConfigured: - # Database is not loaded. This happens in tests. + except (ImproperlyConfigured, OperationalError): + # Database is not loaded. This happens in tests and migrations. pass # Define config variables and projector elements. diff --git a/requirements/development.txt b/requirements/development.txt index e5119b485..b4440966f 100644 --- a/requirements/development.txt +++ b/requirements/development.txt @@ -4,7 +4,7 @@ coverage git+https://gitlab.com/pycqa/flake8.git isort mypy -pytest>=3.7.2 +pytest>=3.6,<3.7 pytest-django pytest-asyncio pytest-cov diff --git a/tests/conftest.py b/tests/conftest.py index d029d2942..d06807c9e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -9,7 +9,7 @@ def pytest_collection_modifyitems(items): Helper until https://github.com/pytest-dev/pytest-django/issues/214 is fixed. """ def get_marker_transaction(test): - marker = test.get_marker('django_db') + marker = test.get_closest_marker('django_db') if marker: validate_django_db(marker) return marker.kwargs['transaction']