Skip to content

Commit

Permalink
Do not patch test if we have a named loader for __opts__
Browse files Browse the repository at this point in the history
  • Loading branch information
dwoz committed Aug 14, 2023
1 parent b2d9349 commit 33e8eb9
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions salt/loader/lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,16 @@ def __call__(self, *args, **kwargs):
# All modules we've imported should have __opts__ defined. There are
# cases in the test suite where mod ends up being something other than
# a module we've loaded.
set_test = False
if hasattr(mod, "__opts__"):
if isinstance(mod.__opts__, salt.loader.context.NamedLoaderContext):
if mod.__opts__.value() is not None:
mod.__opts__.value()["test"] = self.loader.opts["test"]
else:
if not isinstance(mod.__opts__, salt.loader.context.NamedLoaderContext):
mod.__opts__["test"] = self.loader.opts["test"]
set_test = True
if self.loader.inject_globals:
run_func = global_injector_decorator(self.loader.inject_globals)(run_func)
ret = self.loader.run(run_func, *args, **kwargs)
if hasattr(mod, "__opts__"):
if isinstance(mod.__opts__, salt.loader.context.NamedLoaderContext):
if mod.__opts__.value() is not None:
self.loader.opts["test"] = mod.__opts__["test"]
else:
self.loader.opts["test"] = mod.__opts__["test"]
if set_test:
self.loader.opts["test"] = mod.__opts__["test"]
return ret

def __repr__(self):
Expand Down

0 comments on commit 33e8eb9

Please sign in to comment.