Example #1
0
def monkeypatch_behave():
    """
    Apply patches to "behave" to make documenation runs work.
    """
    from behave.formatter import pretty2
    from behave.formatter import ansi_escapes
    from behave.formatter import formatters
    from behave.terminal.ansiterm import AnsiStyle
    from behave.terminal import ansi_escapes as ansi_escapes2
    ansi_escapes.colors["grey"] = ansi_escapes.colors["white"]
    ansi_escapes.use_ansi_escape_colorbold_composites()
    ansi_escapes2.AnsiColor.grey = ansi_escapes2.AnsiColor.white
    ansi_escapes2.colors["grey"] = ansi_escapes.colors["white"]
    AnsiStyle.parse_style = staticmethod(AnsiStyle.parse_style2)
    formatters.register_as(pretty2.SimplePrettyFormatter, "pretty")
Example #2
0

if __name__ == "__main__":
    # TODO: support all other params instead

    class _Null(Formatter):
        """
        Null formater to prevent stdout output
        """
        pass

    command_args = list(filter(None, sys.argv[1:]))
    if command_args:
        _bdd_utils.fix_win_drive(command_args[0])
    my_config = configuration.Configuration(command_args=command_args)
    formatters.register_as(_Null, "com.intellij.python.null")
    my_config.format = ["com.intellij.python.null"]  # To prevent output to stdout
    my_config.reporters = []  # To prevent summary to stdout
    my_config.stdout_capture = False  # For test output
    my_config.stderr_capture = False  # For test output
    (base_dir, what_to_run) = _bdd_utils.get_path_by_env(os.environ)
    features = set()
    for feature in what_to_run:
        if os.path.isfile(feature) or glob.glob(
                os.path.join(feature, "*.feature")):  # File of folder with "features"  provided, load it
            features.add(feature)
        elif os.path.isdir(feature):
            features |= set(_get_dirs_to_run(feature))  # Find "features" subfolder
    my_config.paths = list(features)
    _BehaveRunner(my_config, base_dir).run()
Example #3
0
    (base_dir, scenario_names,
     what_to_run) = _bdd_utils.get_what_to_run_by_env(os.environ)

    for scenario_name in scenario_names:
        command_args += ["-n",
                         re.escape(scenario_name)]  # TODO : rewite pythonic

    my_config = configuration.Configuration(command_args=command_args)

    # Temporary workaround to support API changes in 1.2.5
    if version.LooseVersion(behave_version) >= version.LooseVersion("1.2.5"):
        from behave.formatter import _registry
        _registry.register_as("com.intellij.python.null", _Null)
    else:
        from behave.formatter import formatters
        formatters.register_as(_Null, "com.intellij.python.null")

    my_config.format = ["com.intellij.python.null"
                        ]  # To prevent output to stdout
    my_config.reporters = []  # To prevent summary to stdout
    my_config.stdout_capture = False  # For test output
    my_config.stderr_capture = False  # For test output
    features = set()
    for feature in what_to_run:
        if os.path.isfile(feature) or glob.glob(
                os.path.join(feature, "*.feature")
        ):  # File of folder with "features"  provided, load it
            features.add(feature)
        elif os.path.isdir(feature):
            features |= set(
                _get_dirs_to_run(feature))  # Find "features" subfolder