Esempio n. 1
0
    def test_xml_resource_close(self):
        resource = XMLResource(self.vh_xml_file)
        resource.close()
        xml_file = resource.open()
        self.assertTrue(callable(xml_file.read))

        with open(self.vh_xml_file) as xml_file:
            resource = XMLResource(source=xml_file)
            resource.close()
            with self.assertRaises(ValueError):
                resource.open()
Esempio n. 2
0
    def test_xml_resource_open(self):
        resource = XMLResource(self.vh_xml_file)
        xml_file = resource.open()
        self.assertIsNot(xml_file, resource.source)
        data = xml_file.read().decode('utf-8')
        self.assertTrue(data.startswith('<?xml '))
        xml_file.close()
        resource = XMLResource('<A/>')
        self.assertRaises(ValueError, resource.open)

        resource = XMLResource(source=open(self.vh_xml_file))
        xml_file = resource.open()
        self.assertIs(xml_file, resource.source)
        xml_file.close()
Esempio n. 3
0
 def test_xml_resource_open(self):
     resource = XMLResource(self.vh_xml_file)
     xml_file = resource.open()
     data = xml_file.read().decode('utf-8')
     self.assertTrue(data.startswith('<?xml '))
     xml_file.close()
     resource = XMLResource('<A/>')
     self.assertRaises(ValueError, resource.open)