@@ -176,29 +176,22 @@ def sanity_check_step(self, exts_filter=None, custom_paths=None, custom_commands
176176 # make sure Extension sanity check step is run once, by using a single empty list of extra modules
177177 lists_of_extra_modules = [[]]
178178
179- for extra_modules in lists_of_extra_modules :
180-
181- fake_mod_data = None
182-
183- # only load fake module + extra modules for stand-alone installations (not for extensions),
184- # since for extension the necessary modules should already be loaded at this point;
185- # take into account that module may already be loaded earlier in sanity check
186- if not (self .sanity_check_module_loaded or self .is_extension or self .dry_run ):
187- # load fake module
188- fake_mod_data = self .load_fake_module (purge = True , extra_modules = extra_modules )
189-
190- if extra_modules :
191- info_msg = "Running extension sanity check with extra modules: %s" % ', ' .join (extra_modules )
192- self .log .info (info_msg )
193- trace_msg (info_msg )
194-
195- # perform extension sanity check
179+ # only load fake module + extra modules for stand-alone installations (not for extensions),
180+ # since for extension the necessary modules should already be loaded at this point;
181+ # take into account that module may already be loaded earlier in sanity check
182+ if not (self .sanity_check_module_loaded or self .is_extension or self .dry_run ):
183+ for extra_modules in lists_of_extra_modules :
184+ with self .fake_module_environment (extra_modules = extra_modules ):
185+ if extra_modules :
186+ info_msg = f"Running extension sanity check with extra modules: { ', ' .join (extra_modules )} "
187+ self .log .info (info_msg )
188+ trace_msg (info_msg )
189+ # perform sanity check for stand-alone extension
190+ (sanity_check_ok , fail_msg ) = Extension .sanity_check_step (self )
191+ else :
192+ # perform single sanity check for extension
196193 (sanity_check_ok , fail_msg ) = Extension .sanity_check_step (self )
197194
198- if fake_mod_data :
199- # unload fake module and clean up
200- self .clean_up_fake_module (fake_mod_data )
201-
202195 if custom_paths or custom_commands or not self .is_extension :
203196 super ().sanity_check_step (custom_paths = custom_paths ,
204197 custom_commands = custom_commands ,
0 commit comments