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 saltstack#108

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
  • Loading branch information
s0undt3ch committed Mar 21, 2022
1 parent c95d161 commit 546292a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
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
24 changes: 24 additions & 0 deletions src/saltfactories/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
"""
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:
# pylint: disable=unused-import
from pytestshellutils.exceptions import FactoryNotStarted, FactoryTimeout # noqa: F401

# pylint: enable=unused-import


class SaltFactoriesException(Exception):
Expand Down

0 comments on commit 546292a

Please sign in to comment.