Changeset 8632 for main/waeup.kofa/trunk


Ignore:
Timestamp:
6 Jun 2012, 01:10:51 (13 years ago)
Author:
uli
Message:

Make sure we can cope with 'broken' (empty) CSV file input when
merging CSV files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_helpers.py

    r8631 r8632  
    426426        return
    427427
     428    def test_one_empty_input(self):
     429        # we cope even with nearly empty input (one file with no data)
     430        open(self.path1, 'wb').write('\n')
     431        open(self.path2, 'wb').write('name,age\nManfred,32\n')
     432        self.result_path = helpers.merge_csv_files(self.path1, self.path2)
     433        contents = open(self.result_path, 'r').read()
     434        self.assertEqual(
     435            contents,
     436            'age,name\r\n'
     437            '32,Manfred\r\n')
     438        return
     439
     440    def test_two_empty_inputs(self):
     441        # we cope even with empty input (two files with no data)
     442        open(self.path1, 'wb').write('\n')
     443        open(self.path2, 'wb').write('\n')
     444        self.result_path = helpers.merge_csv_files(self.path1, self.path2)
     445        contents = open(self.result_path, 'r').read()
     446        self.assertEqual(
     447            contents, '\r\n')
     448        return
    428449
    429450def test_suite():
Note: See TracChangeset for help on using the changeset viewer.