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 = 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 = 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: remove_namespaces('foo'))
def test_remove_namespaces_junk_xml_causes_malformed_exception(self): self.assertRaises(MalformedDocxException, lambda: remove_namespaces("foo"))