Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/tests/conftest.py
import os | import os | ||||
import pytest | import pytest | ||||
import glob | import glob | ||||
from datetime import timedelta | from datetime import timedelta | ||||
import pkg_resources | |||||
from swh.core.utils import numfile_sortkey as sortkey | from swh.core.utils import numfile_sortkey as sortkey | ||||
from swh.scheduler import get_scheduler | from swh.scheduler import get_scheduler | ||||
from swh.scheduler.tests import SQL_DIR | from swh.scheduler.tests import SQL_DIR | ||||
# make sure we are not fooled by CELERY_ config environment vars | # make sure we are not fooled by CELERY_ config environment vars | ||||
for var in [x for x in os.environ.keys() if x.startswith('CELERY')]: | for var in [x for x in os.environ.keys() if x.startswith('CELERY')]: | ||||
os.environ.pop(var) | os.environ.pop(var) | ||||
Show All 16 Lines | |||||
@pytest.fixture(scope='session') | @pytest.fixture(scope='session') | ||||
def celery_enable_logging(): | def celery_enable_logging(): | ||||
return True | return True | ||||
@pytest.fixture(scope='session') | @pytest.fixture(scope='session') | ||||
def celery_includes(): | def celery_includes(): | ||||
return [ | task_modules = [ | ||||
'swh.scheduler.tests.tasks', | 'swh.scheduler.tests.tasks', | ||||
] | ] | ||||
vlorentz: Why not toplevel? | |||||
Not Done Inline ActionsI think the rationale is to implement a poor man's lazy policy ;) ardumont: I think the rationale is to implement a `poor man's lazy policy` ;) | |||||
Not Done Inline ActionsIt's a test fixture, it will always run if that file is imported vlorentz: It's a test fixture, it will always run if that file is imported | |||||
Not Done Inline Actionsheh, sounds about right indeed. ardumont: heh, sounds about right indeed. | |||||
Done Inline Actions
Why toplevel? douardda: > Why not toplevel?
Why toplevel? | |||||
Not Done Inline ActionsBecause imports should always be at the toplevel unless there's a reason not to. vlorentz: Because imports should always be at the toplevel unless there's a reason not to. | |||||
for entrypoint in pkg_resources.iter_entry_points('swh.workers'): | |||||
task_modules.extend(entrypoint.load()().get('task_modules', [])) | |||||
return task_modules | |||||
@pytest.fixture(scope='session') | @pytest.fixture(scope='session') | ||||
def celery_parameters(): | def celery_parameters(): | ||||
return { | return { | ||||
'task_cls': 'swh.scheduler.task:SWHTask', | 'task_cls': 'swh.scheduler.task:SWHTask', | ||||
} | } | ||||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |
Why not toplevel?