MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_5027_2

Method test_5027_2

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

Source from the content-addressed store, hash-verified

744 '</a:g1>'))
745
746 def test_5027_2(self):
747 # The xml prefix (as in xml:lang below) is reserved and bound by
748 # definition to http://www.w3.org/XML/1998/namespace. XMLGenerator had
749 # a bug whereby a KeyError is raised because this namespace is missing
750 # from a dictionary.
751 #
752 # This test demonstrates the bug by direct manipulation of the
753 # XMLGenerator.
754 result = self.ioclass()
755 gen = XMLGenerator(result)
756
757 gen.startDocument()
758 gen.startPrefixMapping('a', 'http://example.com/ns')
759 gen.startElementNS(('http://example.com/ns', 'g1'), 'g1', {})
760 lang_attr = {('http://www.w3.org/XML/1998/namespace', 'lang'): 'en'}
761 gen.startElementNS(('http://example.com/ns', 'g2'), 'g2', lang_attr)
762 gen.characters('Hello')
763 gen.endElementNS(('http://example.com/ns', 'g2'), 'g2')
764 gen.endElementNS(('http://example.com/ns', 'g1'), 'g1')
765 gen.endPrefixMapping('a')
766 gen.endDocument()
767
768 self.assertEqual(result.getvalue(),
769 self.xml(
770 '<a:g1 xmlns:a="http://example.com/ns">'
771 '<a:g2 xml:lang="en">Hello</a:g2>'
772 '</a:g1>'))
773
774 def test_no_close_file(self):
775 result = self.ioclass()

Callers

nothing calls this directly

Calls 12

startDocumentMethod · 0.95
startPrefixMappingMethod · 0.95
startElementNSMethod · 0.95
charactersMethod · 0.95
endElementNSMethod · 0.95
endPrefixMappingMethod · 0.95
endDocumentMethod · 0.95
XMLGeneratorClass · 0.90
ioclassMethod · 0.45
assertEqualMethod · 0.45
getvalueMethod · 0.45
xmlMethod · 0.45

Tested by

no test coverage detected