1import unittest
2import xml.etree.ElementTree as ET
3from compare_native import content
4
5
6class NativeComparisonTest(unittest.TestCase):
7 def test_cache_identity_does_not_hide_text_or_formatting_changes(self):
8 source = ET.fromstring('<OE objectID="cache-a" style="font-weight:bold"><T>Text</T></OE>')
9 other = ET.fromstring('<OE objectID="cache-b" style="font-weight:bold"><T>Text</T></OE>')
10 self.assertEqual(content(source), content(other))
11 other.find('T').text = 'Different'
12 self.assertNotEqual(content(source), content(other))
13 other.find('T').text = 'Text'
14 other.set('style', 'font-weight:normal')
15 self.assertNotEqual(content(source), content(other))
16
17 def test_geometry_and_table_order_remain_significant(self):
18 source = ET.fromstring('<Table><Row><Cell>A</Cell><Cell>B</Cell></Row></Table>')
19 other = ET.fromstring('<Table><Row><Cell>B</Cell><Cell>A</Cell></Row></Table>')
20 self.assertNotEqual(content(source), content(other))
21 first = ET.fromstring('<Position x="36" y="72"/>')
22 second = ET.fromstring('<Position x="37" y="72"/>')
23 self.assertNotEqual(content(first), content(second))
24
25
26if __name__ == '__main__':
27 unittest.main()