class TestCompareSectionTable(unittest.TestCase): def setUp(self): self.test_table = CompareSectionTable() self.doc = create_compare_test() odml.tools.xmlparser.XMLWriter(self.doc).write_file("comparetest.odml") def tearDown(self): os.remove("comparetest.odml") def test_loadfromfile(self): self.test_table.load_from_file("comparetest.odml") self.assertEqual(self.doc, self.test_table._odmldoc) def test_choose(self): self.test_table.choose_sections("Section3", "Section1", "One more Section") expected = [ section.name for section in self.doc.itersections( filter_func=lambda x: x.name in ["Section1", "Section3", "One more Section"] ) ] result = [section.name for section in self.doc.itersections(filter_func=self.test_table._sel_fun)] self.assertItemsEqual(expected, result) def test_choose_start(self): self.test_table.choose_sections_startwith("Section") expected = [ section.name for section in self.doc.itersections(filter_func=lambda x: x.name.startswith("Section")) ] result = [section.name for section in self.doc.itersections(filter_func=self.test_table._sel_fun)] self.assertItemsEqual(expected, result)