class ErtShellTestContext(object): def __init__(self, test_name, config_file, load_config=True, prefix=None, store_area=False): self.config_file = config_file self.load_config = load_config self.test_area_context = TestAreaContext(test_name, prefix=prefix, store_area=store_area) def __enter__(self): """ :rtype: ErtShell """ test_area = self.test_area_context.__enter__() test_area.copy_parent_content(self.config_file) self.shell = ErtShell(forget_history=True) config_file = os.path.basename(self.config_file) if self.load_config: self.shell.onecmd("load_config %s" % config_file) return self.shell def __exit__(self, exc_type, exc_val, exc_tb): self.shell.do_exit("") self.shell._cleanup() self.test_area_context.__exit__(exc_type, exc_val, exc_tb) return False
class ErtShellTestContext(object): def __init__(self, test_name, config_file, load_config=True, prefix=None, store_area=False): self.config_file = config_file self.load_config = load_config self.test_area_context = TestAreaContext(test_name, prefix=prefix, store_area=store_area) def __enter__(self): """ :rtype: ErtShell """ test_area = self.test_area_context.__enter__() test_area.copy_parent_content(self.config_file) self.shell = ErtShell(forget_history=True) config_file = os.path.basename(self.config_file) if self.load_config: self.shell.onecmd("load_config %s" % config_file) return self.shell def __exit__(self, exc_type, exc_val, exc_tb): self.shell.do_exit("") self.test_area_context.__exit__(exc_type, exc_val, exc_tb) return False