From: Jan Fajerski Date: Wed, 12 Aug 2020 10:58:29 +0000 (+0200) Subject: pybind/mgr/snap_schedule: fix imports for snap_schedule vs mgr wide tox runs X-Git-Tag: v16.1.0~1299^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6491e53fa1b01c9d14179a58340f16781c2131ab;p=ceph.git pybind/mgr/snap_schedule: fix imports for snap_schedule vs mgr wide tox runs Signed-off-by: Jan Fajerski --- diff --git a/src/pybind/mgr/snap_schedule/__init__.py b/src/pybind/mgr/snap_schedule/__init__.py index 843b447f5407..8001b7184851 100644 --- a/src/pybind/mgr/snap_schedule/__init__.py +++ b/src/pybind/mgr/snap_schedule/__init__.py @@ -2,7 +2,10 @@ from os import environ -if 'UNITTEST' in environ: +if 'SNAP_SCHED_UNITTEST' in environ: import tests +elif 'UNITTEST' in environ: + import tests + from .module import Module else: from .module import Module diff --git a/src/pybind/mgr/snap_schedule/fs/schedule.py b/src/pybind/mgr/snap_schedule/fs/schedule.py index cee7a3c763d9..019d28caa2d3 100644 --- a/src/pybind/mgr/snap_schedule/fs/schedule.py +++ b/src/pybind/mgr/snap_schedule/fs/schedule.py @@ -14,6 +14,9 @@ from typing import Tuple, Any log = logging.getLogger(__name__) +TESTING = 'SNAP_SCHED_TESTING' in environ + + # Work around missing datetime.fromisoformat for < python3.7 SNAP_DB_TS_FORMAT = '%Y-%m-%dT%H:%M:%S' try: @@ -354,7 +357,7 @@ class Schedule(object): def repeat(self): mult = self.schedule[-1] period = int(self.schedule[0:-1]) - if 'SNAP_SCHED_TESTING' in environ and mult == 'M': + if TESTING and mult == 'M': return period * 60 elif mult == 'h': return period * 60 * 60 diff --git a/src/pybind/mgr/snap_schedule/tox.ini b/src/pybind/mgr/snap_schedule/tox.ini index 756dc044bdcd..fbf894b068ee 100644 --- a/src/pybind/mgr/snap_schedule/tox.ini +++ b/src/pybind/mgr/snap_schedule/tox.ini @@ -10,7 +10,7 @@ setenv= PATH = {toxinidir}/../../../../build/bin:$PATH py27: PYTHONPATH = {toxinidir}/../../../../build/lib/cython_modules/lib.2:.. py3: PYTHONPATH = {toxinidir}/../../../../build/lib/cython_modules/lib.3:{toxinidir} - UNITTEST = true + SNAP_SCHED_UNITTEST = true deps = pytest mock