From 03a3c201cb1065f11936deac88ec085ee69f1110 Mon Sep 17 00:00:00 2001 From: Manjinder Singh <49171515+jinder1s@users.noreply.github.com> Date: Tue, 11 Feb 2020 10:38:36 -0500 Subject: [PATCH] Moved hooks around (#23077) This change only implements pytest hooks when we know pytest_json_report plugin has been loaded. Previously, the hooks were being loaded before plugin, thus causing errors cause(pytest_sessionfinish needs the plugin to function). --- cms/conftest.py | 6 ++++-- conftest.py | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cms/conftest.py b/cms/conftest.py index 92a5c0616377..e0a774b805b4 100644 --- a/cms/conftest.py +++ b/cms/conftest.py @@ -12,8 +12,7 @@ import contracts import pytest -from openedx.core.pytest_hooks import pytest_json_modifyreport # pylint: disable=unused-import -from openedx.core.pytest_hooks import pytest_sessionfinish # pylint: disable=unused-import +from openedx.core.pytest_hooks import DeferPlugin # Patch the xml libs before anything else. @@ -35,6 +34,9 @@ def pytest_configure(config): startup = importlib.import_module(startup_module) startup.run() + if config.pluginmanager.hasplugin("json-report"): + config.pluginmanager.register(DeferPlugin()) + @pytest.fixture(autouse=True, scope='function') def _django_clear_site_cache(): diff --git a/conftest.py b/conftest.py index 57ccae529610..345eeef78125 100644 --- a/conftest.py +++ b/conftest.py @@ -10,8 +10,6 @@ # avoid duplicating the implementation from cms.conftest import _django_clear_site_cache, pytest_configure # pylint: disable=unused-import -from openedx.core.pytest_hooks import pytest_json_modifyreport # pylint: disable=unused-import -from openedx.core.pytest_hooks import pytest_sessionfinish # pylint: disable=unused-import # When using self.assertEquals, diffs are truncated. We don't want that, always