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"
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"
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()
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"
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"
# distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import argparse import functools import os import sys from typing import Any, List, Optional, Sequence, Union from nox import _option_set from nox.tasks import discover_manifest, filter_manifest, load_nox_module """All of nox's configuration options.""" options = _option_set.OptionSet( description="Nox is a Python automation toolkit.", add_help=False) options.add_groups( _option_set.OptionGroup( "primary", "Primary arguments", "These are the most common arguments used when invoking Nox.", ), _option_set.OptionGroup( "secondary", "Additional arguments & flags", "These arguments are used to control Nox's behavior or control advanced features.", ), )
def test_namespace_non_existant_options_with_values(self): optionset = _option_set.OptionSet() with pytest.raises(KeyError): optionset.namespace(non_existant_option="meep")