Example #1
0
def test_create_argparser_prefix_str(prefix):
    fqname = _make_fqname(prefix) + ("xval",)
    argname = argument_name(fqname)
    argdest = argument_dest(fqname)
    schema = Schema.from_string("""\
xval = Int(doc="x value")
""", fmt="zirkon")
    parser = create_argparser(schema, prefix=prefix)
    namespace = parser.parse_args(["{}=2".format(argname)])
    assert getattr(namespace, argdest) == 2
Example #2
0
def test_argument_name_int_error():
    with pytest.raises(TypeError):
        argument_name(10)
Example #3
0
def test_argument_name_str():
    assert argument_name("a.b") == "--a-b"
Example #4
0
def test_argument_name_None():
    assert argument_name(None) == "--"
Example #5
0
def test_argument_name_tuple():
    assert argument_name(('a', 'b')) == "--a-b"
Example #6
0
def test_argument_name():
    assert argument_name(("alpha", "max_value")) == "--alpha-max_value"