def location_and_station_set_to(location: int, work_station: int): cfg = Config() old_cfg = deepcopy(cfg.current_config) cfg['GUID_components']['location'] = location cfg['GUID_components']['work_station'] = work_station cfg.save_to_home() try: yield finally: cfg.current_config = old_cfg cfg.save_to_home()
def protected_config(): """ Context manager to be used in all tests that modify the config to ensure that the config is left untouched even if the tests fail """ ocfg: DotDict = Config().current_config original_config = deepcopy(ocfg) try: yield finally: cfg = Config() cfg.current_config = original_config cfg.save_to_home()