示例#1
0
    def test_xml_references(self):
        self.buf.truncate()
        self.buf.seek(0, 0)
        self.buf.append(
            b'\x0f\x00\x00\x00\x19<a><b>hello world</b></a>\x07\x00\x00')

        self.assertEqual(
            xml.tostring(xml.fromstring('<a><b>hello world</b></a>')),
            xml.tostring(self.decoder.readElement()))

        self.assertEqual(
            xml.tostring(xml.fromstring('<a><b>hello world</b></a>')),
            xml.tostring(self.decoder.readElement()))
示例#2
0
    def test_amf3_xml(self):
        self.encoder.use_amf3 = True
        blob = '<root><sections><section /><section /></sections></root>'

        blob = xml.tostring(xml.fromstring(blob))

        bytes = self.encode(xml.fromstring(blob))

        buf = util.BufferedByteStream(bytes)

        self.assertEqual(buf.read_uchar(), 17)
        self.assertEqual(buf.read_uchar(), 11)
        self.assertEqual(buf.read_uchar() >> 1, buf.remaining())
        self.assertEqual(buf.read(), blob)
示例#3
0
 def test_xmlstring(self):
     x = xml.fromstring('<a><b>hello world</b></a>')
     self.assertEqual(self.encode(x), b'\x0b\x33<a><b>hello world</b></a>')
     self.assertEqual(self.encode(x), b'\x0b\x00')
示例#4
0
    def test_xml_references(self):
        blob = b'<a><b>hello world</b></a>'
        x = xml.fromstring(blob)

        self.assertEncoded([x, x], b'\n\x00\x00\x00\x02' +
                           (b'\x0f\x00\x00\x00\x19' + blob) * 2)
示例#5
0
    def test_xml(self):
        blob = b'<a><b>hello world</b></a>'

        self.assertEncoded(xml.fromstring(blob),
                           b'\x0f\x00\x00\x00\x19' + blob)