Пример #1
0
 def test_csv(self):
     result = seq.csv('functional/test/data/test.csv').to_list()
     expect = [['1', '2', '3', '4'], ['a', 'b', 'c', 'd']]
     self.assertEqual(expect, result)
     with open('functional/test/data/test.csv', 'r') as csv_file:
         self.assertEqual(expect, seq.csv(csv_file).to_list())
     with self.assertRaises(ValueError):
         seq.csv(1)
Пример #2
0
 def test_csv(self):
     result = seq.csv('functional/test/data/test.csv').to_list()
     expect = [['1', '2', '3', '4'], ['a', 'b', 'c', 'd']]
     self.assertEqual(expect, result)
     with open('functional/test/data/test.csv', 'r') as csv_file:
         self.assertEqual(expect, seq.csv(csv_file).to_list())
     with self.assertRaises(ValueError):
         seq.csv(1)
Пример #3
0
 def test_to_csv(self):
     tmp_path = 'functional/test/data/tmp/output.txt'
     elements = [[1, 2, 3], [4, 5, 6], ['a', 'b', 'c']]
     expect = [['1', '2', '3'], ['4', '5', '6'], ['a', 'b', 'c']]
     sequence = seq(elements)
     sequence.to_csv(tmp_path)
     result = seq.csv(tmp_path).to_list()
     self.assertEqual(expect, result)
Пример #4
0
 def test_to_csv(self):
     tmp_path = 'functional/test/data/tmp/output.txt'
     elements = [[1, 2, 3], [4, 5, 6], ['a', 'b', 'c']]
     expect = [['1', '2', '3'], ['4', '5', '6'], ['a', 'b', 'c']]
     sequence = seq(elements)
     sequence.to_csv(tmp_path)
     result = seq.csv(tmp_path).to_list()
     self.assertEqual(expect, result)
Пример #5
0
 def test_seq_csv(self):
     f = _make_str_file(u'''
         a,b,c
         11,12,13
         21,22,23
         31,32,33
     ''')
     res = seq.csv(f)
     assert res == [['a', 'b', 'c'], ['11', '12', '13'], ['21', '22', '23'], ['31', '32', '33']]
Пример #6
0
def parse_labels(labels_path):
    return {
        path: label.strip().lower() == 'true'
        for path, label in seq.csv(labels_path).list()
    }