[Zodb-checkins] CVS: Packages/ZConfig/tests - test_loader.py:1.11

Fred L. Drake, Jr. fred@zope.com
Wed, 15 Jan 2003 14:17:45 -0500


Update of /cvs-repository/Packages/ZConfig/tests
In directory cvs.zope.org:/tmp/cvs-serv21083/tests

Modified Files:
	test_loader.py 
Log Message:
Make sure opening a resource that does not exist consistently raises the
same exception.  Includes test.


=== Packages/ZConfig/tests/test_loader.py 1.10 => 1.11 ===
--- Packages/ZConfig/tests/test_loader.py:1.10	Mon Jan 13 12:41:55 2003
+++ Packages/ZConfig/tests/test_loader.py	Wed Jan 15 14:17:42 2003
@@ -15,6 +15,7 @@
 
 import os.path
 import sys
+import tempfile
 import unittest
 
 from StringIO import StringIO
@@ -128,6 +129,23 @@
         self.assertEqual(
             ZConfig.url.urldefrag("file:/abc/def#frag"),
             ("file:///abc/def", "frag"))
+
+    def test_nonexistant_file(self):
+        fn = tempfile.mktemp()
+        schema = ZConfig.loadSchemaFile(StringIO("<schema/>"))
+        self.assertRaises(ZConfig.ConfigurationError,
+                          ZConfig.loadSchema, fn)
+        self.assertRaises(ZConfig.ConfigurationError,
+                          ZConfig.loadConfig, schema, fn)
+        self.assertRaises(ZConfig.ConfigurationError,
+                          ZConfig.loadConfigFile, schema,
+                          StringIO("%include " + fn))
+        self.assertRaises(ZConfig.ConfigurationError,
+                          ZConfig.loadSchema,
+                          "http://www.zope.org/no-such-document/")
+        self.assertRaises(ZConfig.ConfigurationError,
+                          ZConfig.loadConfig, schema,
+                          "http://www.zope.org/no-such-document/")
 
 
 def test_suite():