コード例 #1
0
def test_read_namespace_prefix(simple_schema, pfx):
    parser = create_argparser(simple_schema, prefix=pfx)
    namespace = parser.parse_args(["--pfx-alpha", "456", "--pfx-gamma", "abf"])
    
    print(namespace)
    config, validation = read_namespace(simple_schema, namespace, prefix=pfx)
    assert config['alpha'] == 456
    assert config['gamma'] == "abf"
コード例 #2
0
def test_tdata_config(tdata):
    schema = Schema.from_string(
        """\
{} = {}
""".format(tdata.name, tdata.validator_source),
        fmt="zirkon")
    parser = create_argparser(schema)
    for args, value, parsing_error, validation_error in tdata.checks:
        try:
            namespace = parser.parse_args(args)
        except SystemExit:
            assert parsing_error
            continue
        else:
            assert not parsing_error
        config, validation_result = read_namespace(schema, namespace)
        if validation_error:
            assert validation_result
        else:
            assert not validation_result
        assert config.get(tdata.name) == value
コード例 #3
0
def test_read_namespace_invalid_schema():
    with pytest.raises(TypeError):
        read_namespace([], None)