Move get_scheduler monkeypatching into an explicit pytest fixture
This allows us to actually run the lister instantiation code instead of relying on the underlying structure of the lister object. In turn, this allows future listers to use the scheduler right in their __init__.
This commit is contained in:
parent
d0c1df65f1
commit
211f4610df
3 changed files with 20 additions and 4 deletions
18
conftest.py
18
conftest.py
|
@ -5,6 +5,24 @@
|
|||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
pytest_plugins = ["swh.scheduler.pytest_plugin"]
|
||||
|
||||
os.environ["LC_ALL"] = "C.UTF-8"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_get_scheduler(monkeypatch, swh_scheduler):
|
||||
"""Override the get_scheduler function in swh.lister.core.lister_base, to
|
||||
return the swh_scheduler fixture.
|
||||
"""
|
||||
from swh.lister.core import lister_base
|
||||
|
||||
# Match the signature from swh.scheduler.get_scheduler
|
||||
def get_scheduler(cls, args={}):
|
||||
return swh_scheduler
|
||||
|
||||
monkeypatch.setattr(lister_base, "get_scheduler", get_scheduler)
|
||||
|
||||
yield monkeypatch
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue