Skip to content

AnydataNode.to_xml() fails #80

@kwatsen

Description

@kwatsen

@HRogge

The test_xml_config pytest in test-models.py in my xml-improved fork currently comments-out anydA. But if its removal is commented-out in the xml_safe_data() as follows:

OLD:

data2['test:contA'].pop('anydA')

NEW:

#data2['test:contA'].pop('anydA')

And run:

pytest -sxvv -k test_xml_config

Then the following output is produced:

  <snip/>
        # convert InstanceValue to an XML-encoded string
>       xml_obj = inst.to_xml()

tests/test_model.py:741: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
yangson/instance.py:708: in to_xml
    et = super().to_xml(filter, element)
yangson/instance.py:540: in to_xml
    m.to_xml(filter, child)
yangson/instance.py:540: in to_xml
    m.to_xml(filter, child)
yangson/instance.py:507: in to_xml
    m = self[cname]
yangson/instance.py:219: in __getitem__
    return self._member(key)
yangson/instance.py:580: in _member
    self._member_schema_node(name), self.value.timestamp)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <yangson.instance.ObjectMember object at 0x10777d4f0>, name = 'foo:bar'

    def _member_schema_node(self: InstanceNode, name: InstanceName) -> DataNode:
        qname = self.schema_node._iname2qname(name)
>       res = self.schema_node.get_data_child(*qname)
E       AttributeError: 'AnydataNode' object has no attribute 'get_data_child'

yangson/instance.py:609: AttributeError
=============================================== short test summary info ===============================================
FAILED tests/test_model.py::test_xml_config - AttributeError: 'AnydataNode' object has no attribute 'get_data_child'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================== 1 failed, 15 deselected in 0.67s ===========================================

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions