def wrapper(*args, **kwargs): settings.configure(settings.Settings()) rpc._RESOURCE_PACKAGES.clear() rpc._RESOURCE_MODULES.clear() rpc_manager.RPC_MANAGER = rpc_manager.RPCManager() wrapped(*args, **kwargs)
def my_mocks(): old_settings = settings.SETTINGS mm = MyMocks() mocks.set_mocks(mm, preview=False) try: yield mm finally: settings.configure(old_settings)
def build_dep_tracker(preview: bool = False): old_settings = settings.SETTINGS mm = MinimalMocks() mocks.set_mocks(mm, preview=preview) dt = DependencyTrackingMonitorWrapper(settings.SETTINGS.monitor) settings.SETTINGS.monitor = dt try: yield dt finally: settings.configure(old_settings)
def my_mocks(): settings.reset_options() old_settings = deepcopy(settings.SETTINGS) monitor = MyMonitor() mm = MyMocks() mocks.set_mocks(mm, preview=False, monitor=monitor) try: yield mm finally: settings.configure(old_settings) # Asserts are here in an unusual place since it is tricky to # place them inside a test and make the code run after the # test stack completes constructing. assert monitor.outputs is not None assert type(monitor.outputs.urn) == str