Example #1
0
    def test_namespace_values(self):
        optionset = _option_set.OptionSet()
        optionset.add_options(_option_set.Option("option_a", default="meep"))

        namespace = optionset.namespace(option_a="moop")

        assert namespace.option_a == "moop"
Example #2
0
    def test_namespace(self):
        optionset = _option_set.OptionSet()
        optionset.add_options(_option_set.Option("option_a", default="meep"))

        namespace = optionset.namespace()

        assert hasattr(namespace, "option_a")
        assert not hasattr(namespace, "non_existant_option")
        assert namespace.option_a == "meep"
Example #3
0
    def test_parser_groupless_option(self):
        optionset = _option_set.OptionSet()
        optionset.add_options(
            _option_set.Option("oh_no_i_have_no_group",
                               group=None,
                               default="meep"))

        with pytest.raises(ValueError):
            optionset.parser()
Example #4
0
    def test_namespace_values(self):
        optionset = _option_set.OptionSet()
        optionset.add_groups(_option_set.OptionGroup("group_a"))
        optionset.add_options(
            _option_set.Option("option_a",
                               group=optionset.groups["group_a"],
                               default="meep"))

        namespace = optionset.namespace(option_a="moop")

        assert namespace.option_a == "moop"
Example #5
0
    def test_parser_hidden_option(self):
        optionset = _option_set.OptionSet()
        optionset.add_options(
            _option_set.Option("oh_boy_i_am_hidden",
                               hidden=True,
                               group=None,
                               default="meep"))

        parser = optionset.parser()
        namespace = parser.parse_args([])
        optionset._finalize_args(namespace)

        assert namespace.oh_boy_i_am_hidden == "meep"
Example #6
0
    module = load_nox_module(global_config)
    manifest = discover_manifest(module, global_config)
    filtered_manifest = filter_manifest(manifest, global_config)
    if isinstance(filtered_manifest, int):
        return []
    return [
        session.friendly_name
        for session, _ in filtered_manifest.list_all_sessions()
    ]


options.add_options(
    _option_set.Option(
        "help",
        "-h",
        "--help",
        group=options.groups["primary"],
        action="store_true",
        help="Show this help message and exit.",
    ),
    _option_set.Option(
        "version",
        "--version",
        group=options.groups["primary"],
        action="store_true",
        help="Show the Nox version and exit.",
    ),
    _option_set.Option(
        "list_sessions",
        "-l",
        "--list-sessions",
        "--list",
Example #7
0
    module = load_nox_module(global_config)
    manifest = discover_manifest(module, global_config)
    filtered_manifest = filter_manifest(manifest, global_config)
    if isinstance(filtered_manifest, int):
        return []
    return [
        session.friendly_name
        for session, _ in filtered_manifest.list_all_sessions()
    ]


options.add_options(
    _option_set.Option(
        "help",
        "-h",
        "--help",
        group=options.groups["general"],
        action="store_true",
        help="Show this help message and exit.",
    ),
    _option_set.Option(
        "version",
        "--version",
        group=options.groups["general"],
        action="store_true",
        help="Show the Nox version and exit.",
    ),
    _option_set.Option(
        "list_sessions",
        "-l",
        "--list-sessions",
        "--list",
Example #8
0
def _session_completer(prefix, parsed_args, **kwargs):
    global_config = parsed_args
    module = load_nox_module(global_config)
    manifest = discover_manifest(module, global_config)
    filtered_manifest = filter_manifest(manifest, global_config)
    return [
        session.friendly_name
        for session, _ in filtered_manifest.list_all_sessions()
    ]


options.add_options(
    _option_set.Option(
        "help",
        "-h",
        "--help",
        group="primary",
        action="store_true",
        help="Show this help message and exit.",
    ),
    _option_set.Option(
        "version",
        "--version",
        group="primary",
        action="store_true",
        help="Show the Nox version and exit.",
    ),
    _option_set.Option(
        "list_sessions",
        "-l",
        "--list-sessions",
        "--list",