def handle(path): file_conf = ConfigObj(os.path.join(path, 'features', 'config.ini')) behave_options = file_conf['behave']['options'] conf = Configuration(behave_options) conf.paths = [os.path.join(path, 'features')] runner = Runner(conf) runner.run()
def handle(path, args=None): file_conf = ConfigObj(os.path.join(path, "features", "config.ini")) try: behave_options = file_conf["behave"]["options"] except KeyError: raise ValueError("Behave config not found." " Are you running with the right path?") if args: behave_options += " " + " ".join(args) conf = Configuration(behave_options) conf.paths = [os.path.join(path, "features")] runner = Runner(conf) runner.run()
def handle(path, args=None): file_conf = ConfigObj(os.path.join(path, 'features', 'config.ini')) try: behave_options = file_conf['behave']['options'] except KeyError: raise ValueError("Behave config not found." " Are you running with the right path?") if args: behave_options += ' ' + ' '.join(args) conf = Configuration(behave_options) conf.paths = [os.path.join(path, 'features')] runner = Runner(conf) runner.run()
def handle(path, args=None): file_conf = ConfigObj(os.path.join(path, 'features', 'config.ini')) try: behave_options = file_conf['behave']['options'] except KeyError: raise ValueError("Behave config not found." " Are you running with the right path?") if args: behave_options += ' ' + ' '.join(args) conf = Configuration(behave_options) conf.paths = [os.path.join(path, 'features')] runner = Runner(conf) return runner.run()
def launch_test(self, path, batch_id): c = Configuration("") if not c.format: c.format = [c.default_format] c.paths = [path] c.userdata['lang_code'] = self.lang_code c.userdata['target_id'] = self.target_id c.userdata['base_url'] = self.target_id.target_id.url c.userdata['batch_id'] = batch_id.id c.userdata['scenario_id'] = self.scenario_id.id c.userdata['scenario_line_id'] = self.scenario_line_id.id c.userdata['empty_batch'] = self.empty_batch c.userdata['browser_vm_url'] = self.env[ 'ir.config_parameter'].get_param('test_builder.vm_url') self.config = c r = Runner(c) r.run() if self.scenario_line_id: return r.feature.status else: return c.userdata.get('run_id', None)
def get_config(work_dir): config = Configuration() config.paths = [work_dir] config.format = ['pretty'] return config
def execute_bdd(statechart: Statechart, feature_filepaths: List[str], *, step_filepaths: List[str] = None, property_statecharts: List[Statechart] = None, interpreter_klass: Callable[[Statechart], Interpreter] = Interpreter, debug_on_error: bool = False, behave_parameters: List[str] = None) -> int: """ Execute BDD tests for a statechart. :param statechart: statechart to test :param feature_filepaths: list of filepaths to feature files. :param step_filepaths: list of filepaths to step definitions. :param property_statecharts: list of property statecharts :param interpreter_klass: a callable that accepts a statechart and an optional clock and returns an Interpreter :param debug_on_error: set to True to drop to (i)pdb in case of error. :param behave_parameters: additional CLI parameters used by Behave (see http://behave.readthedocs.io/en/latest/behave.html#command-line-arguments) :return: exit code of behave CLI. """ # Default values step_filepaths = step_filepaths if step_filepaths else [] property_statecharts = property_statecharts if property_statecharts else [] behave_parameters = behave_parameters if behave_parameters else [] # If debug_on_error, disable captured stdout, otherwise it hangs if debug_on_error and '--capture' not in behave_parameters: behave_parameters.append('--no-capture') # Create temporary directory to put everything inside with tempfile.TemporaryDirectory() as tempdir: # Create configuration for Behave config = Configuration(behave_parameters) # Paths to features config.paths = feature_filepaths # Copy environment with open(os.path.join(tempdir, 'environment.py'), 'w') as environment: environment.write('from sismic.bdd.environment import *') # Path to environment config.environment_file = os.path.join(tempdir, 'environment.py') # Add predefined steps os.mkdir(os.path.join(tempdir, 'steps')) with open(os.path.join(tempdir, 'steps', '__steps.py'), 'w') as step: step.write('from sismic.bdd.steps import *') # Copy provided steps, if any for step_filepath in step_filepaths: shutil.copy(step_filepath, os.path.join( tempdir, 'steps', os.path.split(step_filepath)[-1])) # Path to steps config.steps_dir = os.path.join(tempdir, 'steps') # Put statechart and properties in user data config.update_userdata({ 'statechart': statechart, 'interpreter_klass': interpreter_klass, 'property_statecharts': property_statecharts, 'debug_on_error': debug_on_error, }) # Run behave return run_behave(config)