def parse(self): conf = Config() conf.highest_feature_id = 0 conf.highest_scenario_id = 0 conf.highest_step_id = 0 conf.longest_feature_text = 0 self._feature_id = 0 for f in self._feature_files: try: self._features.extend(self._parse_feature(f)) except RadishError: raise except Exception, e: raise FeatureFileNotValidError(f, str(e))
def cli(**kwargs): """radish - The root from red to green. BDD tooling for Python. Parse and Pretty Print the raw radish AST for the given Feature Files Provide the Feature Files to run in FEATURE_FILES. """ config = Config(kwargs) world.config = config # turn of ANSI colors if requested if config.no_ansi: cf.disable() parser = FeatureFileParser( ast_transformer=None, resolve_preconditions=config.resolve_preconditions) for feature_file in config.feature_files: logger.info("Parsing Feature File %s", feature_file) try: feature_ast = parser.parse(feature_file) if feature_ast: print(feature_ast.pretty()) except RadishError as exc: print("", flush=True) print( "An error occured while parsing the Feature File {}:".format( feature_file), flush=True, ) print(exc, flush=True) sys.exit(1)
def cli(**kwargs): """radish - The root from red to green. BDD tooling for Python. radish-test can be used to perform tests for the Steps implemented in a radish base directory. Use the `MATCHER_CONFIGS` to pass configuration files containing the Step matchers. """ config = Config(kwargs) # turn of ANSI colors if requested if config.no_ansi: cf.disable() logger.debug("Basedirs: %s", ", ".join(str(d) for d in config.basedirs)) logger.debug("Loading all modules from the basedirs") loaded_modules = loader.load_modules(config.basedirs) logger.debug( "Loaded %d modules from the basedirs: %s", len(loaded_modules), ", ".join(str(m) for m in loaded_modules), ) logger.debug("Matcher configs: %s", ", ".join(str(m) for m in config.matcher_configs)) coverage_config = CoverageConfig(config.show_missing, config.show_missing_templates) run_matcher_tests(config.matcher_configs, coverage_config, step_registry)
def test_config_parses_tag_expressions(): """The Config object parses Tag Expressions""" # when config = Config({"tags": "foo and bar"}) # then assert config.tag_expression is not None
def test_config_adds_items_as_attributes(): """The Config objects adds its Config Items as object attributes""" # when config = Config({"foo": "bar", "bla": "meh"}) # then assert config.foo == "bar" assert config.bla == "meh"
def setup_default_config(): """Setup a default radish config This config can be used by a components under test for most Test Cases. """ return Config( { "wip_mode": False, "dry_run_mode": False, "debug_steps_mode": False, "tags": None, "tag_expression": None, "scenario_ids": [], "early_exit": False, "shuffle_scenarios": False, "no_ansi": False, } )
def cli(**kwargs): """radish - The root from red to green. BDD tooling for Python. Use radish to run your Feature File. Provide the Feature Files to run in FEATURE_FILES. """ config = Config(kwargs) world.config = config # turn of ANSI colors if requested if config.no_ansi: cf.disable() logger.debug( "Loaded %d built-in extension modules: %s", len(loaded_built_in_extensions), ", ".join(str(e) for e in loaded_built_in_extensions), ) logger.debug("Feature Files: %s", ", ".join(str(p) for p in config.feature_files)) logger.debug("Basedirs: %s", ", ".join(str(d) for d in config.basedirs)) logger.debug("Loading extensions") loaded_extensions = extension_registry.load_extensions(config) logger.debug( "Loaded %d extensions: %s", len(loaded_extensions), ", ".join(type(e).__name__ for e in loaded_extensions), ) parser = FeatureFileParser() features = [] for feature_file in config.feature_files: logger.debug("Parsing Feature File %s", feature_file) try: feature_ast = parser.parse(feature_file) if feature_ast: features.append(feature_ast) except RadishError as exc: print("", flush=True) print( "An error occured while parsing the Feature File {}:".format( feature_file), flush=True, ) print(exc, flush=True) sys.exit(1) logger.debug("Loading all modules from the basedirs") loaded_modules = loader.load_modules(config.basedirs) logger.debug( "Loaded %d modules from the basedirs: %s", len(loaded_modules), ", ".join(str(m) for m in loaded_modules), ) exit_status = 0 try: runner = Runner(config, step_registry=step_registry, hook_registry=hook_registry) logger.debug( "Starting Runner WIP mode: %r, Dry-Run mode: %r", config.wip_mode, config.dry_run_mode, ) success = runner.start(features) logger.debug("Finished Runner with status %s", success) exit_status = 0 if success else 1 except RadishError as exc: print("", flush=True) print("An error occured while running the Feature Files:", flush=True) print(exc, flush=True) exit_status = 1 sys.exit(exit_status)
def log_after_all(endResult): Logger.log("test %s terminated" % (unicode(Config().marker))) Logger.free()
def log_before_all(): Logger.init() Logger.log("starting test %s" % (unicode(Config().marker)))
def test_config_raise_error_for_invalid_tag_expressions(): """The Config object should raise an Error for an invalid Tag Expression""" # then with pytest.raises(RadishError): # when Config({"tags": "foo and"})