diff --git a/lib/galaxy_test/base/api.py b/lib/galaxy_test/base/api.py index 26aa1d0932f1..4e6c096d3e50 100644 --- a/lib/galaxy_test/base/api.py +++ b/lib/galaxy_test/base/api.py @@ -49,11 +49,22 @@ def handle_galaxy_config_kwds(cls, config): config["celery_broker"] = CELERY_BROKER config["celery_backend"] = CELERY_BACKEND - @pytest.fixture(autouse=True) + @pytest.fixture(autouse=True, scope="session") def _request_celery_app(self, celery_session_app, celery_config): - self._celery_app = celery_session_app + try: + self._celery_app = celery_session_app + yield + finally: + if os.environ.get("GALAXY_TEST_EXTERNAL") is None: + try: + from galaxy.celery import celery_app + except ImportError: + return + + celery_app.fork_pool.stop() + celery_app.fork_pool.join(timeout=5) - @pytest.fixture(autouse=True) + @pytest.fixture(autouse=True, scope="session") def _request_celery_worker(self, celery_session_worker, celery_config): self._celery_worker = celery_session_worker diff --git a/lib/galaxy_test/conftest.py b/lib/galaxy_test/conftest.py index e02521849418..1e7e3b45106f 100644 --- a/lib/galaxy_test/conftest.py +++ b/lib/galaxy_test/conftest.py @@ -12,15 +12,7 @@ @pytest.fixture(scope="session", autouse=True) def celery_includes(): - try: - yield ["galaxy.celery.tasks"] - finally: - from galaxy.celery import celery_app - - fork_pool = getattr(celery_app, "fork_pool", None) - if fork_pool: - fork_pool.stop() - fork_pool.join(timeout=5) + yield ["galaxy.celery.tasks"] def get_timings(test_uuid):