def test_remove_namespaces_on_namespaceless_xml(self): xml = b'<?xml version="1.0"?><one><two><three/><three/></two></one>' expected = '<one><two><three/><three/></two></one>' result = xml_remove_namespaces(xml) assert isinstance(result, bytes) result = remove_whitespace(result.decode('utf-8')) self.assertEqual(result, expected)
def test_remove_namespaces(self): xml = b'''<?xml version="1.0"?> <w:one xmlns:w="foo"> <w:two> <w:three/> <w:three/> </w:two> </w:one> ''' expected = '<one><two><three/><three/></two></one>' result = xml_remove_namespaces(xml) assert isinstance(result, bytes) result = remove_whitespace(result.decode('utf-8')) self.assertEqual(result, expected)
def test_remove_namespaces_junk_xml_causes_malformed_exception(self): self.assertRaises(MalformedDocxException, lambda: xml_remove_namespaces('foo'))
def test_remove_namespaces_junk_xml_causes_malformed_exception(self): self.assertRaises( MalformedDocxException, lambda: xml_remove_namespaces('foo') )