def run_scenario(self, lines): lines = [' ' + line for line in lines] lines.insert(0, '- ') lines.insert(0, '- zaffy repl scenario') raw_str = "\n".join(lines) setting = ScenarioSetting(body=raw_str) new_scenario = scenario_loader.load(setting) if not self.scenario: self.scenario = new_scenario self.scenario.run(self.global_env) else: self.scenario.add_action(new_scenario.actions[0]) self.scenario.run(self.global_env)
def _load(self, path, global_env, scenario, params): path = path.strip() if os.path.isabs(path): if self._root_path: path = self._replace_root(path, self._root_path) else: path = os.path.join(scenario.dir, path) new_scenario = scenario_loader.load(ScenarioSetting(path), scenario) new_scenario.localvar = self._to_dict(params) new_scenario.run(global_env) return new_scenario
def do_require(self, path, global_env, scenario, params=None): path = path.strip() if not path: raise Exception(path + " not exists") if not os.path.isabs(path): if self.root_path: path = os.path.join(self.root_path, path) else: path = os.path.join(scenario.dir, path) new_scenario = scenario_loader.load(ScenarioSetting(path), scenario) new_scenario.localvar = params if params else {} new_scenario.run(global_env) self.result = new_scenario.actions[-1].result
def add_files(self, file_list): filter = self.filter for target in file_list: scenario = scenario_loader.load(ScenarioSetting(filename=target)) if self.is_valid(scenario): self.add(scenario)
def add_files(self, file_list): for target in file_list: scenario = scenario_loader.load(ScenarioSetting(filename=target)) self.add(scenario)