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
def test_make_fqname(prefix): fqname = _make_fqname(prefix) if prefix is None: assert _make_fqname(prefix) == () elif isinstance(prefix, str): assert _make_fqname(prefix) == tuple(prefix.split(".")) elif isinstance(fqname, tuple): assert _make_fqname(prefix) is prefix else: with pytest.raises(TypeError): _make_fqname(prefix)