Skip to content

Commit

Permalink
Backwards compatible imports for exceptions that are now in pytest-sh…
Browse files Browse the repository at this point in the history
…ell-utilities

Fixes #108

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
  • Loading branch information
s0undt3ch committed Mar 21, 2022
1 parent c95d161 commit fa8aa6a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .pylint-spelling-words
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ darwin
datatypes
datetime
deepcopy
defaultdict
dereference
destpath
dmux
Expand Down Expand Up @@ -90,6 +91,7 @@ localhost
macos
maxdepth
minify
mixin
msg
msgpack
mtime
Expand Down Expand Up @@ -196,10 +198,13 @@ towncrier
txt
un
undoc
unicode
unix
uss
utils
venv
versionadded
virtualenv
virtualenvs
yaml
zmq
1 change: 1 addition & 0 deletions changelog/108.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Provide backwards compatibility imports for the old factory exceptions, now in pytest-shell-utilities
26 changes: 26 additions & 0 deletions src/saltfactories/exceptions.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down

0 comments on commit fa8aa6a

Please sign in to comment.