Skip to content

Commit

Permalink
Fix element signature for builtin AnyType
Browse files Browse the repository at this point in the history
  • Loading branch information
bozokopic committed Mar 11, 2024
1 parent 377d931 commit fbcae2c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/zeep/xsd/elements/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ def resolve(self):
def signature(self, schema=None, standalone=True):
from zeep.xsd import ComplexType

if self.type.is_global or (not standalone and self.is_global):
if ((self.type.is_global and self.type.qname is not None) or
(not standalone and self.is_global)):
value = self.type.get_prefixed_name(schema)
else:
value = self.type.signature(schema, standalone=False)
Expand Down
12 changes: 12 additions & 0 deletions tests/test_xsd_signatures.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pytest
from lxml import etree

from tests.utils import load_xml
Expand Down Expand Up @@ -289,3 +290,14 @@ def test_schema_recursive_ref():

elm = schema.get_element("ns0:Container")
elm.signature(schema)


@pytest.mark.parametrize('default_type', xsd.default_types.values())
@pytest.mark.parametrize('standalone', [True, False])
def test_signature_builtin_type(default_type, standalone):
builtin_type = xsd.Element(
etree.QName("http://tests.python-zeep.org/", "authentication"),
default_type
)
signature = builtin_type.signature(standalone=standalone)
assert isinstance(signature, str)

0 comments on commit fbcae2c

Please sign in to comment.