diff --git a/pytest.ini b/pytest.ini index 43961e54e9..ebb0a6beb5 100644 --- a/pytest.ini +++ b/pytest.ini @@ -3,7 +3,7 @@ norecursedirs = .git .* static __pycache__ build DJANGO_SETTINGS_MODULE = server.tests.settings python_files = tests.py test_*.py *_tests.py testpaths = server -addopts = -rsxX --showlocals --tb=native --nomigrations --flake8 --staticfiles --isort --cov-report term --cov-report xml --cov server +addopts = -rsxX --showlocals --tb=native --reuse-db --nomigrations --flake8 --staticfiles --isort --cov-report term --cov-report xml --cov server env = GITHUB_CLIENT_ID= GITHUB_CLIENT_SECRET= diff --git a/server/tests/conftest.py b/server/tests/conftest.py index fd323b33eb..72dd45893b 100644 --- a/server/tests/conftest.py +++ b/server/tests/conftest.py @@ -1,12 +1,17 @@ import datetime +import logging +import time import pytest from rest_framework.test import APIClient +from spinach.contrib.spinachd.apps import spin from server.base.models import User from server.files.models import File, FileSource from server.notebooks.models import Notebook, NotebookRevision +logger = logging.getLogger(__name__) + def pytest_configure(config): # work-around for https://github.com/ktosiek/pytest-freezegun/issues/13 @@ -16,6 +21,19 @@ def pytest_configure(config): ) +@pytest.fixture(scope="session", autouse=True) +def spinach_worker(request): + spin.start_workers(number=1, block=False) + logger.info("Starting Spinach workers.") + + def stop_workers(): + spin.stop_workers() + logging.info("Stopping Spinach workers.") + time.sleep(2) + + request.addfinalizer(stop_workers) + + @pytest.fixture def api_client(): """