def inner(*args, **kwargs): model = Model(func.func_name, _export=False) # manually set up SelfExporter, targeting func's globals SelfExporter.default_model = model SelfExporter.target_module = func.__module__ SelfExporter.target_globals = func.func_globals SelfExporter.target_globals['model'] = model # call the actual test function func(*args, **kwargs) # clean up the globals SelfExporter.cleanup()
def inner(*args, **kwargs): model = Model(func.__name__, _export=False) # manually set up SelfExporter, targeting func's globals selfexporter_state = SelfExporter.do_export SelfExporter.do_export = True SelfExporter.default_model = model SelfExporter.target_module = func.__module__ SelfExporter.target_globals = func.__globals__ SelfExporter.target_globals['model'] = model try: # call the actual test function func(*args, **kwargs) finally: # clean up the globals SelfExporter.cleanup() SelfExporter.do_export = selfexporter_state