Ejemplo n.º 1
0
    def test_iterates_csv_with_header(self):
        from collections import OrderedDict

        data = arrayfiles.read_csv(self.fp.name, header=True)
        header = self.lines[0].split(',')
        expected = [
            OrderedDict(zip(header, line.split(',')))
            for line in self.lines[1:]
        ]
        for i, (x, y) in enumerate(zip(data, expected)):
            self.assertEqual(x, y)
            self.assertEqual(data[i], y)
Ejemplo n.º 2
0
 def test_eager_load(self):
     text1 = arrayfiles.read_csv(self.fp.name, lazy=False)
     text2 = arrayfiles.read_csv(self.fp.name, lazy=True)
     for a, b in zip(text1, text2):
         self.assertEqual(a, b)
Ejemplo n.º 3
0
 def test_iterates_csv_without_header(self):
     data = arrayfiles.read_csv(self.fp.name, header=False)
     expected = [line.split(',') for line in self.lines]
     self.assertSequenceEqual(data, expected)
     for x, y in zip(data, expected):
         self.assertEqual(x, y)
Ejemplo n.º 4
0
 def test_loads_csv_with_header(self):
     data = arrayfiles.read_csv(self.fp.name, header=True)
     self.assertTrue(data._header)
Ejemplo n.º 5
0
 def test_slices_items(self):
     data = arrayfiles.read_csv(self.fp.name)
     self.assertSequenceEqual(data[:len(self.lines)], data)
Ejemplo n.º 6
0
 def test_dunder_init(self):
     data = arrayfiles.read_csv(self.fp.name)
     self.assertEqual(data._path, self.fp.name)
     self.assertEqual(data._encoding, 'utf-8')
     self.assertEqual(data._delimiter, ',')
     self.assertFalse(data._header)