Skip to content

Instantly share code, notes, and snippets.

@arjenjb
Created March 1, 2017 16:31
Show Gist options
  • Save arjenjb/76f8a96a158d9ec27e288e91ea88b9d9 to your computer and use it in GitHub Desktop.
Save arjenjb/76f8a96a158d9ec27e288e91ea88b9d9 to your computer and use it in GitHub Desktop.
def test_nested_choice():
schema = xsd.Schema(load_xml("""
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://tests.python-zeep.org/"
targetNamespace="http://tests.python-zeep.org/"
elementFormDefault="qualified">
<element name="container">
<complexType>
<sequence>
<choice>
<choice minOccurs="2" maxOccurs="unbounded">
<element ref="tns:a" />
</choice>
<element ref="tns:b" />
</choice>
</sequence>
</complexType>
</element>
<element name="a" type="string" />
<element name="b" type="string" />
</schema>
"""))
schema.set_ns_prefix('tns', 'http://tests.python-zeep.org/')
container_type = schema.get_element('tns:container')
expected = etree.fromstring("""
<container xmlns="http://tests.python-zeep.org/">
<b>1</b>
</container>
""")
container_type.parse(expected, None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment