Skip to content

Commit

Permalink
Moved hooks around (openedx#23077)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
jinder1s authored Feb 11, 2020
1 parent cce8cdd commit 03a3c20
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 4 additions & 2 deletions cms/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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():
Expand Down
2 changes: 0 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 03a3c20

Please sign in to comment.