From fbcae2cd7de598fe63f1ce533ce8d103a002ba66 Mon Sep 17 00:00:00 2001 From: "bozo.kopic" Date: Mon, 11 Mar 2024 03:13:44 +0100 Subject: [PATCH] Fix element signature for builtin AnyType Fixes #1348 --- src/zeep/xsd/elements/element.py | 3 ++- tests/test_xsd_signatures.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/zeep/xsd/elements/element.py b/src/zeep/xsd/elements/element.py index 1650f75a9..a72d04f7d 100644 --- a/src/zeep/xsd/elements/element.py +++ b/src/zeep/xsd/elements/element.py @@ -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) diff --git a/tests/test_xsd_signatures.py b/tests/test_xsd_signatures.py index 48f3be8e9..e21133de3 100644 --- a/tests/test_xsd_signatures.py +++ b/tests/test_xsd_signatures.py @@ -1,3 +1,4 @@ +import pytest from lxml import etree from tests.utils import load_xml @@ -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)