[Zope-Checkins] CVS: Packages/ZConfig/tests - test_loader.py:1.7
Fred L. Drake, Jr.
fred@zope.com
Wed, 8 Jan 2003 00:41:48 -0500
Update of /cvs-repository/Packages/ZConfig/tests
In directory cvs.zope.org:/tmp/cvs-serv30281
Modified Files:
test_loader.py
Log Message:
Include a test based on Python's test.test_urlparse module, since our
versions of urlsplit() and urlunsplit() were not being exercised in
the tests.
=== Packages/ZConfig/tests/test_loader.py 1.6 => 1.7 ===
--- Packages/ZConfig/tests/test_loader.py:1.6 Tue Jan 7 15:01:00 2003
+++ Packages/ZConfig/tests/test_loader.py Wed Jan 8 00:41:44 2003
@@ -21,8 +21,7 @@
import ZConfig
import ZConfig.loader
-
-from ZConfig.url import urljoin
+import ZConfig.url
from ZConfig.tests.test_config import CONFIG_BASE
@@ -40,14 +39,14 @@
def test_schema_caching(self):
loader = ZConfig.loader.SchemaLoader()
- url = urljoin(CONFIG_BASE, "simple.xml")
+ url = ZConfig.url.urljoin(CONFIG_BASE, "simple.xml")
schema1 = loader.loadURL(url)
schema2 = loader.loadURL(url)
self.assert_(schema1 is schema2)
def test_schema_components(self):
loader = ZConfig.loader.SchemaLoader()
- url = urljoin(CONFIG_BASE, "library.xml")
+ url = ZConfig.url.urljoin(CONFIG_BASE, "library.xml")
schema = loader.loadURL(url)
type_a = loader.loadURL(url + "#type-a")
type_b = loader.loadURL(url + "#type-b")
@@ -59,13 +58,13 @@
def test_simple_import_with_cache(self):
loader = ZConfig.loader.SchemaLoader()
- url1 = urljoin(CONFIG_BASE, "library.xml")
+ url1 = ZConfig.url.urljoin(CONFIG_BASE, "library.xml")
schema1 = loader.loadURL(url1)
sio = StringIO("<schema>"
" <import src='library.xml'/>"
" <section type='type-a' name='section'/>"
"</schema>")
- url2 = urljoin(CONFIG_BASE, "stringio")
+ url2 = ZConfig.url.urljoin(CONFIG_BASE, "stringio")
schema2 = loader.loadFile(sio, url2)
self.assert_(schema1.gettype("type-a") is schema2.gettype("type-a"))
@@ -103,6 +102,30 @@
sio = StringIO("<thing-ext thing/>")
conf, handlers = ZConfig.loadConfigFile(schema, sio)
self.assertEqual(conf.thing.thing_ext_key, "thing-ext-default")
+
+ def test_urlsplit_urlunsplit(self):
+ # Extracted from Python's test.test_urlparse module:
+ for url, parsed, split in [
+ ('http://www.python.org',
+ ('http', 'www.python.org', '', '', '', ''),
+ ('http', 'www.python.org', '', '', '')),
+ ('http://www.python.org#abc',
+ ('http', 'www.python.org', '', '', '', 'abc'),
+ ('http', 'www.python.org', '', '', 'abc')),
+ ('http://www.python.org/#abc',
+ ('http', 'www.python.org', '/', '', '', 'abc'),
+ ('http', 'www.python.org', '/', '', 'abc')),
+ ("http://a/b/c/d;p?q#f",
+ ('http', 'a', '/b/c/d', 'p', 'q', 'f'),
+ ('http', 'a', '/b/c/d;p', 'q', 'f')),
+ ('file:///tmp/junk.txt',
+ ('file', '', '/tmp/junk.txt', '', '', ''),
+ ('file', '', '/tmp/junk.txt', '', '')),
+ ]:
+ result = ZConfig.url.urlsplit(url)
+ self.assertEqual(result, split)
+ result2 = ZConfig.url.urlunsplit(result)
+ self.assertEqual(result2, url)
def test_suite():