def write_test_file(file_name='test_dir' + os.sep + 'test.csv'):
        csv_file = CsvFileHandle(file_name)

        # dict1['corrected_guess'] > dict2['corrected_guess']
        dict1 = OrderedDict(spanish='ayudar',english='to help',correct_guesses='3')
        dict2 = OrderedDict(spanish='buscar',english='to search',correct_guesses='1')
        test_list = [dict1,dict2]

        csv_file.write(test_list)
    def test_csvfilehandle_write(self):
        clean_test_dir()
        write_example_csv()
        csv_file = CsvFileHandle('test_dir/example.csv')
        csv_list = csv_file.read()

        clean_test_dir()
        csv_file.write(csv_list)

        with open('test_dir/example.csv', 'r') as f:
            text = f.read()

        expected = 'spanish,english,correct_guesses\nayudar,to help,0\nbuscar,to search,0\n'
        self.assertEqual(expected, text)
Esempio n. 3
0
 def write_word_list(self):
     """ write self.word_list info to a file """
     file_name = self.file_name
     csv_file = CsvFileHandle(file_name)
     csv_file.write(self.word_list)