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).
This commit is contained in:
@@ -12,8 +12,7 @@ import os
|
||||
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():
|
||||
|
||||
@@ -10,8 +10,6 @@ import pytest
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user