From 680ea5a4e056e540a4212c41c22fdbf62694db5d Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Fri, 10 Mar 2006 23:26:22 +0000 Subject: [PATCH] Tests for QDom. Fixed silly bug introduced by optimisations. git-svn-id: file:///home/talex/Backups/sf.net/Subversion/zero-install/trunk/0launch@701 9f8c893c-44ee-0310-b757-c8ca8341c71e --- tests/testqdom.py | 73 ++++++++++++++++++++++++++++++++++++++++++ zeroinstall/injector/policy.py | 1 - 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100755 tests/testqdom.py diff --git a/tests/testqdom.py b/tests/testqdom.py new file mode 100755 index 0000000..601e4a1 --- /dev/null +++ b/tests/testqdom.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python2.3 +import sys, tempfile, os, shutil +from StringIO import StringIO +import unittest + +sys.path.insert(0, '..') + +from zeroinstall.injector import qdom + +def parseString(s): + return qdom.parse(StringIO(s)) + +class TestQDom(unittest.TestCase): + def testSimple(self): + root = parseString('') + assert root.name == 'root' + assert root.uri == None + assert root.content == '' + + def testText(self): + root = parseString(' Hi ') + assert root.name == 'root' + assert root.uri == None + assert root.content == 'Hi' + assert root.children == [] + + def testNS(self): + root = parseString('' + + '') + assert root.name == 'root' + assert root.uri == 'http://myns.com/foo' + assert root.content == '' + assert root.children == [] + + def testAttrs(self): + root = parseString('' + + '') + assert root.name == 'root' + assert root.uri == None + assert root.content == '' + assert root.children == [] + + assert root.attrs.get('http://myns.com/foo foo') == 'bar' + assert root.attrs.get('bar') == 'baz' + + def testNested(self): + root = parseString('' + + 'Bob3') + assert root.name == 'root' + assert root.uri == None + assert root.content == '' + assert len(root.children) == 2 + + assert root.children[0].name == 'name' + assert root.children[0].uri == None + assert root.children[0].content == 'Bob' + assert root.children[0].children == [] + + assert root.children[1].name == 'age' + assert root.children[1].uri == None + assert root.children[1].content == '3' + assert root.children[1].children == [] + + def testStr(self): + "Mainly, this is for coverage." + root = parseString('' + + 'hi') + assert 'root' in str(root) + +suite = unittest.makeSuite(TestQDom) +if __name__ == '__main__': + sys.argv.append('-v') + unittest.main() diff --git a/zeroinstall/injector/policy.py b/zeroinstall/injector/policy.py index 7496b15..33a13e5 100644 --- a/zeroinstall/injector/policy.py +++ b/zeroinstall/injector/policy.py @@ -283,7 +283,6 @@ class Policy(object): return iter(self.implementation) def check_signed_data(self, download, signed_data): - from zeroinstall.injector import download iface_cache.check_signed_data(download.interface, signed_data, self.handler) def get_cached(self, impl): -- 2.11.4.GIT