| 80 | cls.funcs = salt.loader.minion_mods(cls.opts, utils=cls.utils, proxy=cls.proxy) |
| 81 | |
| 82 | def setUp(self): |
| 83 | # Setup the module |
| 84 | self.module_dir = tempfile.mkdtemp(dir=RUNTIME_VARS.TMP) |
| 85 | self.addCleanup(shutil.rmtree, self.module_dir, ignore_errors=True) |
| 86 | self.module_file = os.path.join(self.module_dir, f"{self.module_name}.py") |
| 87 | with salt.utils.files.fopen(self.module_file, "w") as fh: |
| 88 | fh.write(salt.utils.stringutils.to_str(loader_template)) |
| 89 | fh.flush() |
| 90 | os.fsync(fh.fileno()) |
| 91 | |
| 92 | # Invoke the loader |
| 93 | self.loader = salt.loader.lazy.LazyLoader( |
| 94 | [self.module_dir], |
| 95 | copy.deepcopy(self.opts), |
| 96 | pack={ |
| 97 | "__utils__": self.utils, |
| 98 | "__salt__": self.funcs, |
| 99 | "__proxy__": self.proxy, |
| 100 | }, |
| 101 | tag="module", |
| 102 | ) |
| 103 | |
| 104 | def tearDown(self): |
| 105 | del self.module_dir |