예제 #1
0
 def test_import_component_twice_2(self):
     # Make sure we can import a component from a config file even
     # if it has already been imported from the schema.
     loader = ZConfig.loader.SchemaLoader()
     sio = StringIO("<schema>"
                    "  <import package='ZConfig.tests.library.widget' />"
                    "</schema>")
     schema = loader.loadFile(sio)
     loader = ZConfig.loader.ConfigLoader(schema)
     sio = StringIO("%import ZConfig.tests.library.widget")
     loader.loadFile(sio)
예제 #2
0
 def test_import_component_twice_2(self):
     # Make sure we can import a component from a config file even
     # if it has already been imported from the schema.
     loader = ZConfig.loader.SchemaLoader()
     sio = StringIO("<schema>"
                    "  <import package='ZConfig.tests.library.widget' />"
                    "</schema>")
     schema = loader.loadFile(sio)
     loader = ZConfig.loader.ConfigLoader(schema)
     sio = StringIO("%import ZConfig.tests.library.widget")
     loader.loadFile(sio)
예제 #3
0
 def test_import_from_package_with_missing_file(self):
     loader = ZConfig.loader.SchemaLoader()
     sio = StringIO("<schema>"
                    "  <import package='ZConfig.tests.library.widget'"
                    "          file='notthere.xml' />"
                    "</schema>")
     with self.assertRaises(ZConfig.SchemaResourceError) as ctx:
         loader.loadFile(sio)
     e = ctx.exception
     self.assertEqual(e.filename, "notthere.xml")
     self.assertEqual(e.package, "ZConfig.tests.library.widget")
     self.assertTrue(e.path)
     # make sure the str() doesn't raise an unexpected exception
     str(e)
예제 #4
0
 def test_import_from_package_with_missing_file(self):
     loader = ZConfig.loader.SchemaLoader()
     sio = StringIO("<schema>"
                    "  <import package='ZConfig.tests.library.widget'"
                    "          file='notthere.xml' />"
                    "</schema>")
     with self.assertRaises(ZConfig.SchemaResourceError) as ctx:
         loader.loadFile(sio)
     e = ctx.exception
     self.assertEqual(e.filename, "notthere.xml")
     self.assertEqual(e.package, "ZConfig.tests.library.widget")
     self.assertTrue(e.path)
     # make sure the str() doesn't raise an unexpected exception
     str(e)
예제 #5
0
 def test_import_from_package(self):
     loader = ZConfig.loader.SchemaLoader()
     sio = StringIO("<schema>"
                    "  <import package='ZConfig.tests.library.widget'/>"
                    "</schema>")
     schema = loader.loadFile(sio)
     self.assertTrue(schema.gettype("widget-a") is not None)
예제 #6
0
 def test_import_from_package(self):
     loader = ZConfig.loader.SchemaLoader()
     sio = StringIO("<schema>"
                    "  <import package='ZConfig.tests.library.widget'/>"
                    "</schema>")
     schema = loader.loadFile(sio)
     self.assertTrue(schema.gettype("widget-a") is not None)
예제 #7
0
 def test_import_from_package_extra_directory(self):
     loader = ZConfig.loader.SchemaLoader()
     sio = StringIO("<schema>"
                    "  <import package='ZConfig.tests.library.thing'"
                    "          file='extras.xml' />"
                    "</schema>")
     schema = loader.loadFile(sio)
     self.assertTrue(schema.gettype("extra-thing") is not None)
예제 #8
0
 def test_import_from_package_extra_directory(self):
     loader = ZConfig.loader.SchemaLoader()
     sio = StringIO("<schema>"
                    "  <import package='ZConfig.tests.library.thing'"
                    "          file='extras.xml' />"
                    "</schema>")
     schema = loader.loadFile(sio)
     self.assertTrue(schema.gettype("extra-thing") is not None)
예제 #9
0
 def test_import_from_package_with_file(self):
     loader = ZConfig.loader.SchemaLoader()
     sio = StringIO("<schema>"
                    "  <import package='ZConfig.tests.library.widget'"
                    "          file='extra.xml' />"
                    "</schema>")
     schema = loader.loadFile(sio)
     self.assert_(schema.gettype("extra-type") is not None)
예제 #10
0
 def test_import_from_package_with_file(self):
     loader = ZConfig.loader.SchemaLoader()
     sio = StringIO("<schema>"
                    "  <import package='ZConfig.tests.library.widget'"
                    "          file='extra.xml' />"
                    "</schema>")
     schema = loader.loadFile(sio)
     self.assert_(schema.gettype("extra-type") is not None)
예제 #11
0
 def test_import_two_components_one_package(self):
     loader = ZConfig.loader.SchemaLoader()
     sio = StringIO("<schema>"
                    "  <import package='ZConfig.tests.library.widget' />"
                    "  <import package='ZConfig.tests.library.widget'"
                    "          file='extra.xml' />"
                    "</schema>")
     schema = loader.loadFile(sio)
     schema.gettype("widget-a")
     schema.gettype("extra-type")
예제 #12
0
 def test_import_two_components_one_package(self):
     loader = ZConfig.loader.SchemaLoader()
     sio = StringIO("<schema>"
                    "  <import package='ZConfig.tests.library.widget' />"
                    "  <import package='ZConfig.tests.library.widget'"
                    "          file='extra.xml' />"
                    "</schema>")
     schema = loader.loadFile(sio)
     schema.gettype("widget-a")
     schema.gettype("extra-type")
예제 #13
0
 def test_simple_import_with_cache(self):
     loader = ZConfig.loader.SchemaLoader()
     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 = ZConfig.url.urljoin(CONFIG_BASE, "stringio")
     schema2 = loader.loadFile(sio, url2)
     self.assertTrue(schema1.gettype("type-a") is schema2.gettype("type-a"))
예제 #14
0
 def test_simple_import_with_cache(self):
     loader = ZConfig.loader.SchemaLoader()
     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 = ZConfig.url.urljoin(CONFIG_BASE, "stringio")
     schema2 = loader.loadFile(sio, url2)
     self.assertTrue(schema1.gettype("type-a") is schema2.gettype("type-a"))
예제 #15
0
 def test_import_component_twice_1(self):
     # Make sure we can import a component twice from a schema.
     # This is most likely to occur when the component is imported
     # from each of two other components, or from the top-level
     # schema and a component.
     loader = ZConfig.loader.SchemaLoader()
     sio = StringIO("<schema>"
                    "  <import package='ZConfig.tests.library.widget' />"
                    "  <import package='ZConfig.tests.library.widget' />"
                    "</schema>")
     schema = loader.loadFile(sio)
     schema.gettype("widget-a")
예제 #16
0
 def test_import_component_twice_1(self):
     # Make sure we can import a component twice from a schema.
     # This is most likely to occur when the component is imported
     # from each of two other components, or from the top-level
     # schema and a component.
     loader = ZConfig.loader.SchemaLoader()
     sio = StringIO("<schema>"
                    "  <import package='ZConfig.tests.library.widget' />"
                    "  <import package='ZConfig.tests.library.widget' />"
                    "</schema>")
     schema = loader.loadFile(sio)
     schema.gettype("widget-a")