def test_load() -> None:
    spec = specparser.Spec.loads('\n    [meta]\n    version = 0\n\n    [enum]\n    user_level = ["beginner", "intermediate", "advanced"]\n\n    [directive._parent]\n    content_type = "block"\n    options.foo = ["path", "uri"]\n\n    [directive.child]\n    inherit = "_parent"\n    argument_type = "user_level"\n    deprecated = true\n\n    [role._parent]\n    help = "test-role"\n    type = "text"\n\n    [role.child]\n    inherit = "_parent"\n\n    [rstobject._parent]\n    help = "test-rstobject"\n\n    [rstobject.child]\n    inherit = "_parent"\n    ')
    assert (spec.meta.version == 0)
    assert (spec.enum['user_level'] == ['beginner', 'intermediate', 'advanced'])
    assert (spec.directive['child'] == specparser.Directive(inherit='_parent', example=None, help=None, content_type='block', argument_type='user_level', required_context=None, deprecated=True, domain=None, options={'foo': [specparser.PrimitiveType.path, specparser.PrimitiveType.uri]}, name='child'))
    assert (spec.rstobject['child'].help == 'test-rstobject')
    assert (spec.role['child'].help == 'test-role')
    assert (spec.role['child'].type == specparser.PrimitiveRoleType.text)
    validator = spec.get_validator([specparser.PrimitiveType.nonnegative_integer, 'user_level'])
    assert (validator('10') == 10)
    assert (validator('intermediate') == 'intermediate')
    with pytest.raises(ValueError):
        validator('-10')
    with pytest.raises(ValueError):
        validator('foo')
def test_load() -> None:
    spec = specparser.Spec.loads('\n    [meta]\n    version = 0\n\n    [enum]\n    user_level = ["beginner", "intermediate", "advanced"]\n\n    [directive._parent]\n    content_type = "block"\n    options.foo = ["path", "uri"]\n\n    [directive.child]\n    inherit = "_parent"\n    argument_type = "user_level"\n    deprecated = true\n\n    [role._parent]\n    help = "test-role"\n    type = "text"\n\n    [role.child]\n    inherit = "_parent"\n\n    [rstobject._parent]\n    help = "test-rstobject"\n\n    [rstobject.child]\n    inherit = "_parent"\n    ')
    assert (spec.meta.version == 0)
    assert (spec.enum['user_level'] == ['beginner', 'intermediate', 'advanced'])
    assert (spec.directive['child'] == specparser.Directive(inherit='_parent', example=None, help=None, content_type='block', argument_type='user_level', required_context=None, deprecated=True, domain=None, options={'foo': [specparser.PrimitiveType.path, specparser.PrimitiveType.uri]}, name='child'))
    assert (spec.rstobject['child'].help == 'test-rstobject')
    assert (spec.role['child'].help == 'test-role')
    assert (spec.role['child'].type == specparser.PrimitiveRoleType.text)
    validator = spec.get_validator([specparser.PrimitiveType.nonnegative_integer, 'user_level'])
    assert (validator('10') == 10)
    assert (validator('intermediate') == 'intermediate')
    with pytest.raises(ValueError):
        validator('-10')
    with pytest.raises(ValueError):
        validator('foo')