MCPcopy Create free account
hub / github.com/python/cpython / test_expat_nsattrs_wattr

Method test_expat_nsattrs_wattr

Lib/test/test_sax.py:1098–1119  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1096 self.verify_empty_nsattrs(gather._attrs)
1097
1098 def test_expat_nsattrs_wattr(self):
1099 parser = create_parser(1)
1100 gather = self.AttrGatherer()
1101 parser.setContentHandler(gather)
1102
1103 parser.feed("<doc xmlns:ns='%s' ns:attr='val'/>" % ns_uri)
1104 parser.close()
1105
1106 attrs = gather._attrs
1107
1108 self.assertEqual(attrs.getLength(), 1)
1109 self.assertEqual(attrs.getNames(), [(ns_uri, "attr")])
1110 self.assertTrue((attrs.getQNames() == [] or
1111 attrs.getQNames() == ["ns:attr"]))
1112 self.assertEqual(len(attrs), 1)
1113 self.assertIn((ns_uri, "attr"), attrs)
1114 self.assertEqual(attrs.get((ns_uri, "attr")), "val")
1115 self.assertEqual(attrs.get((ns_uri, "attr"), 25), "val")
1116 self.assertEqual(list(attrs.items()), [((ns_uri, "attr"), "val")])
1117 self.assertEqual(list(attrs.values()), ["val"])
1118 self.assertEqual(attrs.getValue((ns_uri, "attr")), "val")
1119 self.assertEqual(attrs[(ns_uri, "attr")], "val")
1120
1121 # ===== InputSource support
1122

Callers

nothing calls this directly

Calls 15

create_parserFunction · 0.90
listClass · 0.85
getLengthMethod · 0.80
getNamesMethod · 0.80
assertTrueMethod · 0.80
assertInMethod · 0.80
getValueMethod · 0.80
setContentHandlerMethod · 0.45
feedMethod · 0.45
closeMethod · 0.45
assertEqualMethod · 0.45
getQNamesMethod · 0.45

Tested by

no test coverage detected