Exemplo n.º 1
0
def test_xml_name_property_with_compound_name(name, ns_prefix, sec_ns_prefix,
                                              ns_uri):
    compound_name = sec_ns_prefix + '__' + name
    n = NSComponentName(compound_name, ns_prefix, ns_uri)
    assert n.xml_name == (ns_uri or '', name)
    n = NSComponentName(compound_name, ns_prefix=ns_prefix, ns_uri=ns_uri)
    assert n.xml_name == (ns_uri or '', name)
Exemplo n.º 2
0
def test_priv_name_property_with_compound_name(name, ns_prefix, sec_ns_prefix,
                                               ns_uri):
    compound_name = sec_ns_prefix + '__' + name
    n = NSComponentName(compound_name, ns_prefix, ns_uri)
    assert n.priv_name == '__' + compound_name
    n = NSComponentName(compound_name, ns_prefix=ns_prefix, ns_uri=ns_uri)
    assert n.priv_name == '__' + compound_name
Exemplo n.º 3
0
def test_init_name_and_prefix_only(name, ns_prefix, ns_uri):
    with pytest.raises(NoNamespaceURIError, match=re.escape(ns_prefix)):
        NSComponentName(name, ns_prefix)
    with pytest.raises(NoNamespaceURIError, match=re.escape(ns_prefix)):
        NSComponentName(name, ns_prefix=ns_prefix)
    with pytest.raises(NoNamespaceURIError, match=re.escape(ns_prefix)):
        NSComponentName(name, ns_prefix, ns_uri)
    with pytest.raises(NoNamespaceURIError, match=re.escape(ns_prefix)):
        NSComponentName(name, ns_prefix, ns_uri=ns_uri)
Exemplo n.º 4
0
def test_implemented_comparison_v1(name, ns_prefix, ns_uri):
    n1 = NSComponentName(name, ns_prefix, ns_uri)
    n2 = NSComponentName(name, ns_uri=ns_uri, ns_prefix=ns_prefix)
    n3 = NSComponentName(name + '9', ns_prefix, ns_uri)
    assert n1 == n2
    assert n2 == n1
    assert n1 != n3
    assert n3 != n1
    assert n2 != n3
    assert n3 != n2
Exemplo n.º 5
0
def test_init_compound_name_and_prefix_only(name, ns_prefix, sec_ns_prefix,
                                            ns_uri):
    compound_name = sec_ns_prefix + '__' + name
    with pytest.raises(NoNamespaceURIError, match=re.escape(ns_prefix)):
        NSComponentName(compound_name, ns_prefix)
    with pytest.raises(NoNamespaceURIError, match=re.escape(ns_prefix)):
        NSComponentName(compound_name, ns_prefix=ns_prefix)
    with pytest.raises(NoNamespaceURIError, match=re.escape(ns_prefix)):
        NSComponentName(compound_name, ns_prefix, ns_uri)
    with pytest.raises(NoNamespaceURIError, match=re.escape(ns_prefix)):
        NSComponentName(compound_name, ns_prefix, ns_uri=ns_uri)
Exemplo n.º 6
0
def test_comparison_v2(name, ns_prefix, ns_uri):
    n1 = NSComponentName(name, ns_prefix, ns_uri)
    n2 = NSComponentName(name, ns_uri=ns_uri, ns_prefix=ns_prefix)
    n3 = NSComponentName(name + '9', ns_prefix, ns_uri)
    n4 = NSComponentName(name, ns_prefix, ns_uri + '2')
    assert n1 == n2
    assert n2 == n1
    assert n1 != n3
    assert n3 != n1
    assert n2 != n3
    assert n3 != n2
    assert n1 != n4
    assert n4 != n1
    assert n2 != n4
    assert n4 != n2
    assert n3 != n4
    assert n4 != n3
Exemplo n.º 7
0
def test_comparison_with_compound_name(name, ns_prefix, sec_ns_prefix, ns_uri):
    compound_name = sec_ns_prefix + '__' + name
    n1 = NSComponentName(compound_name, ns_prefix, ns_uri)
    n2 = NSComponentName(compound_name, ns_uri=ns_uri, ns_prefix=ns_prefix)
    n3 = NSComponentName(compound_name + '9', ns_prefix, ns_uri)
    n4 = NSComponentName(compound_name, ns_prefix, ns_uri + '2')
    assert n1 == n2
    assert n2 == n1
    assert n1 != n3
    assert n3 != n1
    assert n2 != n3
    assert n3 != n2
    assert n1 != n4
    assert n4 != n1
    assert n2 != n4
    assert n4 != n2
    assert n3 != n4
    assert n4 != n3
Exemplo n.º 8
0
def test_init_name_only(name, ns_prefix, ns_uri):
    NSComponentName(name)
    NSComponentName(name, ns_prefix)
    NSComponentName(name, ns_prefix=ns_prefix)
    NSComponentName(name, ns_uri=ns_uri)
    NSComponentName(name, ns_prefix, ns_uri)
    NSComponentName(name, ns_prefix=ns_prefix)
    NSComponentName(name, ns_prefix=ns_prefix, ns_uri=ns_uri)
Exemplo n.º 9
0
def test_unsupported_comparison(name, ns_prefix, ns_uri):
    n = NSComponentName(name, ns_prefix, ns_uri)
    with pytest.raises(NotImplementedError):
        n == (ns_uri, name)
    with pytest.raises(NotImplementedError):
        (ns_uri, name) == n
    with pytest.raises(NotImplementedError):
        n.pub_name == n
    with pytest.raises(NotImplementedError):
        n == n.pub_name
Exemplo n.º 10
0
def test_unsupported_comparison_with_compound_name(name, ns_prefix,
                                                   sec_ns_prefix, ns_uri):
    compound_name = sec_ns_prefix + '__' + name
    n = NSComponentName(compound_name, ns_prefix, ns_uri)
    with pytest.raises(NotImplementedError):
        n == (ns_uri, name)
    with pytest.raises(NotImplementedError):
        (ns_uri, name) == n
    with pytest.raises(NotImplementedError):
        n.pub_name == n
    with pytest.raises(NotImplementedError):
        n == n.pub_name
Exemplo n.º 11
0
def test_xml_name_property(name, ns_prefix, ns_uri):
    n = NSComponentName(name, ns_prefix, ns_uri)
    assert n.xml_name == (ns_uri or '', name)
    n = NSComponentName(name, ns_prefix=ns_prefix, ns_uri=ns_uri)
    assert n.xml_name == (ns_uri or '', name)
Exemplo n.º 12
0
def test_get_namespaces_with_compound_name_v2(name, ns_prefix, sec_ns_prefix,
                                              ns_uri):
    compound_name = sec_ns_prefix + '__' + name
    n = NSComponentName(compound_name, ns_prefix, ns_uri)
    assert n.get_namespaces() == {(ns_prefix, ns_uri)}
Exemplo n.º 13
0
def test_get_namespaces_v2(name, ns_prefix, ns_uri):
    n = NSComponentName(name, ns_prefix, ns_uri)
    assert n.get_namespaces() == {(ns_prefix or '', ns_uri)}
Exemplo n.º 14
0
def test_get_namespaces_v1(name, ns_prefix, ns_uri):
    n = NSComponentName(name, ns_prefix, ns_uri)
    namespaces = n.get_namespaces()
    assert isinstance(namespaces, set)
    assert namespaces == set()
Exemplo n.º 15
0
def test_repr_with_compound_name_v2(name, ns_prefix, sec_ns_prefix, ns_uri):
    compound_name = sec_ns_prefix + '__' + name
    n = NSComponentName(compound_name, ns_prefix, ns_uri)
    assert repr(
        n) == "NSComponentName(name={!r}, ns_prefix={!r}, ns_uri={!r})".format(
            name, ns_prefix, ns_uri)
Exemplo n.º 16
0
def test_repr(name, ns_prefix, ns_uri):
    n = NSComponentName(name, ns_prefix, ns_uri)
    assert repr(
        n) == "NSComponentName(name={!r}, ns_prefix={!r}, ns_uri={!r})".format(
            name, ns_prefix or '', ns_uri or '')
Exemplo n.º 17
0
def test_init_compound_name_prefix_uri(name, ns_prefix, sec_ns_prefix, ns_uri):
    compound_name = sec_ns_prefix + '__' + name
    NSComponentName(compound_name, ns_uri=ns_uri)
    NSComponentName(compound_name, ns_prefix, ns_uri)
    NSComponentName(compound_name, ns_prefix=ns_prefix, ns_uri=ns_uri)
Exemplo n.º 18
0
def test_pub_name_property(name, ns_prefix, ns_uri):
    n = NSComponentName(name, ns_prefix, ns_uri)
    assert n.pub_name == name
    n = NSComponentName(name, ns_prefix=ns_prefix, ns_uri=ns_uri)
    assert n.pub_name == name
Exemplo n.º 19
0
def test_str(name, ns_prefix, ns_uri):
    n = NSComponentName(name, ns_prefix, ns_uri)
    assert str(n) == name
    n = NSComponentName(name, ns_prefix=ns_prefix, ns_uri=ns_uri)
    assert str(n) == name
Exemplo n.º 20
0
def test_init_name_prefix_uri(name, ns_prefix, ns_uri):
    NSComponentName(name, ns_uri=ns_uri)
    NSComponentName(name, ns_prefix, ns_uri)
    NSComponentName(name, ns_prefix=ns_prefix, ns_uri=ns_uri)
Exemplo n.º 21
0
def test_priv_name_property(name, ns_prefix, ns_uri):
    n = NSComponentName(name, ns_prefix, ns_uri)
    assert n.priv_name == '__' + name
    n = NSComponentName(name, ns_prefix=ns_prefix, ns_uri=ns_uri)
    assert n.priv_name == '__' + name
Exemplo n.º 22
0
def test_str_with_compound_name(name, ns_prefix, sec_ns_prefix, ns_uri):
    compound_name = sec_ns_prefix + '__' + name
    n = NSComponentName(compound_name, ns_prefix, ns_uri)
    assert str(n) == compound_name
    n = NSComponentName(compound_name, ns_prefix=ns_prefix, ns_uri=ns_uri)
    assert str(n) == compound_name