def setUp(self):

        self.test_table = CompareSectionCsvTable()
        self.doc = create_compare_test()
        odml.tools.xmlparser.XMLWriter(self.doc).write_file("comparetest.odml")
        self.test_table.load_from_file("comparetest.odml")
        self.test_table.choose_sections_startwith("")
class TestCompareCsv(unittest.TestCase):
    def setUp(self):

        self.test_table = CompareSectionCsvTable()
        self.doc = create_compare_test()
        odml.tools.xmlparser.XMLWriter(self.doc).write_file("comparetest.odml")
        self.test_table.load_from_file("comparetest.odml")
        self.test_table.choose_sections_startwith("")

    def tearDown(self):
        os.remove("comparetest.odml")
        os.remove("test.csv")

    def test_includeall_true(self):
        self.test_table.include_all = True
        self.test_table.switch = False
        self.test_table.write2file("test.csv")
        with open("test.csv", "rb") as csvfile:
            csvreader = csv.reader(csvfile)
            row_num = 0
            for row in csvreader:
                self.assertEqual(row, include_true_expected[row_num])
                row_num += 1

    def test_includeall_false(self):
        self.test_table.include_all = False
        self.test_table.switch = False
        self.test_table.choose_sections_startwith("S")
        self.test_table.write2file("test.csv")
        with open("test.csv", "rb") as csvfile:
            csvreader = csv.reader(csvfile)
            row_num = 0
            for row in csvreader:
                self.assertEqual(row, include_false_expected[row_num])
                row_num += 1

    def test_switch(self):
        self.test_table.switch = True
        self.test_table.include_all = True
        self.test_table.write2file("test.csv")
        with open("test.csv", "rb") as csvfile:
            csvreader = csv.reader(csvfile)
            row_num = 0
            for row in csvreader:
                self.assertEqual(row, switch_expected[row_num])
                row_num += 1