def test_xmlschema_resolvers_root(self):
     # test that the default resolver will get called if there's no
     # specific parser resolver.
     root_resolver = self.simple_resolver(self.resolver_schema_ext)
     etree.get_default_parser().resolvers.add(root_resolver)
     schema_doc = etree.parse(self.resolver_schema_int)
     schema = etree.XMLSchema(schema_doc)
     etree.get_default_parser().resolvers.remove(root_resolver)
 def test_xmlschema_resolvers_root(self):
     """Test that the default resolver will get called if there's no
     specific parser resolver."""
     root_resolver = self.simple_resolver(self.resolver_schema_ext)
     etree.get_default_parser().resolvers.add(root_resolver)
     schema_doc = etree.parse(self.resolver_schema_int)
     schema = etree.XMLSchema(schema_doc)
     etree.get_default_parser().resolvers.remove(root_resolver)
    def test_xmlschema_resolvers_noroot(self):
        """Test that the default resolver will not get called when a more
        specific resolver is registered."""
        class res_root(etree.Resolver):
            def resolve(self, url, id, context):
                assert False
                return None

        root_resolver = res_root()
        etree.get_default_parser().resolvers.add(root_resolver)

        parser = etree.XMLParser()
        parser.resolvers.add(self.simple_resolver(self.resolver_schema_ext))

        schema_doc = etree.parse(self.resolver_schema_int, parser=parser)
        schema = etree.XMLSchema(schema_doc)
        etree.get_default_parser().resolvers.remove(root_resolver)
    def test_xmlschema_resolvers_noroot(self):
        # test that the default resolver will not get called when a
        # more specific resolver is registered.

        class res_root(etree.Resolver):
            def resolve(self, url, id, context):
                assert False
                return None

        root_resolver = res_root()
        etree.get_default_parser().resolvers.add(root_resolver)

        parser = etree.XMLParser()
        parser.resolvers.add(self.simple_resolver(self.resolver_schema_ext))

        schema_doc = etree.parse(self.resolver_schema_int, parser = parser)
        schema = etree.XMLSchema(schema_doc)
        etree.get_default_parser().resolvers.remove(root_resolver)