Mercurial > bitten > bitten-test
view bitten/util/tests/xmlio.py @ 615:d960021f902f
Added external module for testing `bitten.util.xmlio` - specifically currently parses `UCS-4`-encoding `build` data
author | dfraser |
---|---|
date | Wed, 05 Aug 2009 09:29:55 +0000 |
parents | |
children | 9c135b1a3b60 |
line wrap: on
line source
# -*- coding: utf-8 -*- # # Copyright (C) 2005-2007 Christopher Lenz <cmlenz@gmx.de> # Copyright (C) 2007 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://bitten.edgewall.org/wiki/License. import os import shutil import tempfile import unittest from bitten.util import xmlio class XMLIOTestCase(unittest.TestCase): def test_parse_ucs_4(self): """Tests that UCS-4/UTF-38-encoded data is parsed correctly""" s = """<\x00\x00\x00b\x00\x00\x00u\x00\x00\x00i\x00\x00\x00l\x00\x00\x00d\x00\x00\x00 \x00\x00\x00x\x00\x00\x00m\x00\x00\x00l\x00\x00\x00n\x00\x00\x00s\x00\x00\x00:\x00\x00\x00c\x00\x00\x00=\x00\x00\x00"\x00\x00\x00h\x00\x00\x00t\x00\x00\x00t\x00\x00\x00p\x00\x00\x00:\x00\x00\x00/\x00\x00\x00/\x00\x00\x00b\x00\x00\x00i\x00\x00\x00t\x00\x00\x00t\x00\x00\x00e\x00\x00\x00n\x00\x00\x00.\x00\x00\x00c\x00\x00\x00m\x00\x00\x00l\x00\x00\x00e\x00\x00\x00n\x00\x00\x00z\x00\x00\x00.\x00\x00\x00n\x00\x00\x00e\x00\x00\x00t\x00\x00\x00/\x00\x00\x00t\x00\x00\x00o\x00\x00\x00o\x00\x00\x00l\x00\x00\x00s\x00\x00\x00/\x00\x00\x00c\x00\x00\x00"\x00\x00\x00>\x00\x00\x00 \x00\x00\x00 \x00\x00\x00 \x00\x00\x00 \x00\x00\x00<\x00\x00\x00s\x00\x00\x00t\x00\x00\x00e\x00\x00\x00p\x00\x00\x00 \x00\x00\x00i\x00\x00\x00d\x00\x00\x00=\x00\x00\x00"\x00\x00\x00b\x00\x00\x00u\x00\x00\x00i\x00\x00\x00l\x00\x00\x00d\x00\x00\x00"\x00\x00\x00 \x00\x00\x00d\x00\x00\x00e\x00\x00\x00s\x00\x00\x00c\x00\x00\x00r\x00\x00\x00i\x00\x00\x00p\x00\x00\x00t\x00\x00\x00i\x00\x00\x00o\x00\x00\x00n\x00\x00\x00=\x00\x00\x00"\x00\x00\x00C\x00\x00\x00o\x00\x00\x00n\x00\x00\x00f\x00\x00\x00i\x00\x00\x00g\x00\x00\x00u\x00\x00\x00r\x00\x00\x00e\x00\x00\x00 \x00\x00\x00a\x00\x00\x00n\x00\x00\x00d\x00\x00\x00 \x00\x00\x00b\x00\x00\x00u\x00\x00\x00i\x00\x00\x00l\x00\x00\x00d\x00\x00\x00"\x00\x00\x00>\x00\x00\x00 \x00\x00\x00 \x00\x00\x00 \x00\x00\x00 \x00\x00\x00 \x00\x00\x00 \x00\x00\x00<\x00\x00\x00c\x00\x00\x00:\x00\x00\x00c\x00\x00\x00o\x00\x00\x00n\x00\x00\x00f\x00\x00\x00i\x00\x00\x00g\x00\x00\x00u\x00\x00\x00r\x00\x00\x00e\x00\x00\x00 \x00\x00\x00/\x00\x00\x00>\x00\x00\x00 \x00\x00\x00 \x00\x00\x00 \x00\x00\x00 \x00\x00\x00<\x00\x00\x00/\x00\x00\x00s\x00\x00\x00t\x00\x00\x00e\x00\x00\x00p\x00\x00\x00>\x00\x00\x00 \x00\x00\x00 \x00\x00\x00<\x00\x00\x00/\x00\x00\x00b\x00\x00\x00u\x00\x00\x00i\x00\x00\x00l\x00\x00\x00d\x00\x00\x00>\x00\x00\x00""" s = s.decode("UTF-32").encode("UTF-8") x = xmlio.parse(s) assert x.name == "build" def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(XMLIOTestCase, 'test')) return suite if __name__ == '__main__': unittest.main(defaultTest='suite')