[Zope3-checkins] CVS: Packages/ZConfig/tests - test_loader.py:1.1.2.3
Fred L. Drake, Jr.
fred@zope.com
Tue, 24 Dec 2002 15:51:43 -0500
Update of /cvs-repository/Packages/ZConfig/tests
In directory cvs.zope.org:/tmp/cvs-serv10925
Modified Files:
Tag: zconfig-schema-devel-branch
test_loader.py
Log Message:
Tests for the new URL helpers.
=== Packages/ZConfig/tests/test_loader.py 1.1.2.2 => 1.1.2.3 ===
--- Packages/ZConfig/tests/test_loader.py:1.1.2.2 Mon Dec 23 11:21:58 2002
+++ Packages/ZConfig/tests/test_loader.py Tue Dec 24 15:51:42 2002
@@ -11,7 +11,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Tests of ZConfig.loader classes."""
+"""Tests of ZConfig.loader classes and helper functions."""
import StringIO
import unittest
@@ -20,6 +20,8 @@
import ZConfig
import ZConfig.loader
+from ZConfig.url import urljoin, urlsplit
+
from ZConfig.tests.test_config import CONFIG_BASE
@@ -55,6 +57,30 @@
url2 = urlparse.urljoin(CONFIG_BASE, "stringio")
schema2 = loader.loadFile(sio, url2)
self.assert_(schema1.gettype("type-a") is schema2.gettype("type-a"))
+
+ def test_zconfig_resource(self):
+ loader = ZConfig.loader.SchemaLoader()
+ r = loader.openResource("zconfig:schema.dtd")
+ self.assert_(r.fragment is None)
+ self.assertEqual(r.url, "zconfig:schema.dtd")
+ # just make sure we can read it; we don't care about the content:
+ self.assert_(r.readline())
+ self.assert_(not r.closed)
+ r.close()
+ self.assert_(r.closed)
+
+ def test_urlsplit(self):
+ parts = urlsplit("zconfig:path/to/resource/file.txt#fragment")
+ self.assertEqual(parts, ("zconfig", '', "path/to/resource/file.txt",
+ '', "fragment"))
+ parts = urlsplit("path/to/resource/file.txt#fragment", "zconfig")
+ self.assertEqual(parts, ('', '', "path/to/resource/file.txt",
+ '', "fragment"))
+ self.assertRaises(ValueError, urlsplit, "zconfig://host")
+ self.assertRaises(ValueError, urlsplit, "zconfig:host?query")
+
+ s = urljoin("zconfig:path/file.txt#oldfrag", "../newpath/foo.xml")
+ self.assertEqual(s, "zconfig:newpath/foo.xml")
def test_suite():