diff --git a/.pylint-spelling-words b/.pylint-spelling-words index ff131687..bc72cc4c 100644 --- a/.pylint-spelling-words +++ b/.pylint-spelling-words @@ -39,6 +39,7 @@ darwin datatypes datetime deepcopy +defaultdict dereference destpath dmux @@ -90,6 +91,7 @@ localhost macos maxdepth minify +mixin msg msgpack mtime @@ -196,10 +198,13 @@ towncrier txt un undoc +unicode unix uss utils venv +versionadded virtualenv virtualenvs +yaml zmq diff --git a/changelog/108.bugfix.rst b/changelog/108.bugfix.rst new file mode 100644 index 00000000..623a1325 --- /dev/null +++ b/changelog/108.bugfix.rst @@ -0,0 +1 @@ +Provide backwards compatibility imports for the old factory exceptions, now in pytest-shell-utilities diff --git a/src/saltfactories/exceptions.py b/src/saltfactories/exceptions.py index 11df8306..418151ff 100644 --- a/src/saltfactories/exceptions.py +++ b/src/saltfactories/exceptions.py @@ -1,6 +1,32 @@ """ PyTest Salt Factories related exceptions. """ +import sys + +if sys.version_info >= (3, 7): + + def __getattr__(name): + if name in ("FactoryTimeout", "FactoryNotStarted"): + import pytestshellutils.exceptions + from saltfactories.utils import warn_until + + warn_until( + "2.0.0", + "The '{}' exception is now in 'pytestshellutils.exceptions' and importing it " + "from 'saltfactories.exceptions' is deprecated and will cease to work after " + "pytest-salt-factories {{version}}.".format(name), + ) + return getattr(pytestshellutils.exceptions, name) + else: + raise AttributeError("module '{}' has no '{}' attribute".format(__name__, name)) + +else: + from pytestshellutils.exceptions import ( # noqa: F401 pylint: disable=unused-import + FactoryNotStarted, + ) + from pytestshellutils.exceptions import ( # noqa: F401 pylint: disable=unused-import + FactoryTimeout, + ) class SaltFactoriesException(Exception):