@@ -270,7 +270,7 @@ def testCoreItem_LayoutSetter(dummyGUI):
270270# END Test testCoreItem_LayoutSetter
271271
272272@pytest .mark .core
273- def testCoreItem_XMLPackUnpack (dummyGUI ):
273+ def testCoreItem_XMLPackUnpack (dummyGUI , caplog ):
274274 """Test packing and unpacking XML objects for the NWItem class.
275275 """
276276 theProject = NWProject (dummyGUI )
@@ -370,31 +370,33 @@ def testCoreItem_XMLPackUnpack(dummyGUI):
370370 # Errors
371371
372372 ## Not an Item
373- xDummy = etree .SubElement (nwXML , "stuff" )
374- assert not theItem .unpackXML (xDummy )
373+ mockXml = etree .SubElement (nwXML , "stuff" )
374+ assert theItem .unpackXML (mockXml ) is False
375375
376376 ## Item without Handle
377- xDummy = etree .SubElement (nwXML , "item" , attrib = {"stuff" : "nah" })
378- assert not theItem .unpackXML (xDummy )
377+ mockXml = etree .SubElement (nwXML , "item" , attrib = {"stuff" : "nah" })
378+ assert theItem .unpackXML (mockXml ) is False
379379
380- ## Item with Invalid SubElement
381- xDummy = etree .SubElement (nwXML , "item" , attrib = {"handle" : "0123456789abc" })
382- xParam = etree .SubElement (xDummy , "invalid" )
380+ ## Item with Invalid SubElement is Accepted w/Error
381+ mockXml = etree .SubElement (nwXML , "item" , attrib = {"handle" : "0123456789abc" })
382+ xParam = etree .SubElement (mockXml , "invalid" )
383383 xParam .text = "stuff"
384- assert not theItem .unpackXML (xDummy )
384+ caplog .clear ()
385+ assert theItem .unpackXML (mockXml ) is True
386+ assert "Unknown tag 'invalid'" in caplog .text
385387
386388 # Pack Valid Item
387- xDummy = etree .SubElement (nwXML , "group" )
388- theItem ._subPack (xDummy , "subGroup" , {"one" : "two" }, "value" , False )
389- assert etree .tostring (xDummy , pretty_print = False , encoding = "utf-8" ) == (
389+ mockXml = etree .SubElement (nwXML , "group" )
390+ theItem ._subPack (mockXml , "subGroup" , {"one" : "two" }, "value" , False )
391+ assert etree .tostring (mockXml , pretty_print = False , encoding = "utf-8" ) == (
390392 b"<group><subGroup one=\" two\" >value</subGroup></group>"
391393 )
392394
393395 # Pack Not Allowed None
394- xDummy = etree .SubElement (nwXML , "group" )
395- assert theItem ._subPack (xDummy , "subGroup" , {}, None , False ) is None
396- assert theItem ._subPack (xDummy , "subGroup" , {}, "None" , False ) is None
397- assert etree .tostring (xDummy , pretty_print = False , encoding = "utf-8" ) == (
396+ mockXml = etree .SubElement (nwXML , "group" )
397+ assert theItem ._subPack (mockXml , "subGroup" , {}, None , False ) is None
398+ assert theItem ._subPack (mockXml , "subGroup" , {}, "None" , False ) is None
399+ assert etree .tostring (mockXml , pretty_print = False , encoding = "utf-8" ) == (
398400 b"<group/>"
399401 )
400402
0 commit comments