Exemple #1
0
 def test_as_csv(self):
     "Csv contextmanager"
     p = Path(self.tmpath)
     p << '1,2,3,4'
     with p.csv() as csv:
         for i, row in enumerate(csv):
             self.assertEqual(0, i)
             self.assertEqual('1 2 3 4'.split(), row)
Exemple #2
0
 def test_as_csv(self):
     "Csv contextmanager"
     p = Path(self.tmpath)
     p << '1,2,3,4'
     with p.csv() as csv:
         for i, row in enumerate(csv):
             self.assertEqual(0, i)
             self.assertEqual('1 2 3 4'.split(), row)
Exemple #3
0
 def test_as_csv_header(self):
     "Csv contextmanager with header"
     p = Path(self.tmpath)
     p << 'a,b,c,d\n'
     p << '1,2,3,4'
     with p.csv(header=True) as csv:
         row = csv.next()
         self.assertEqual('1', row.a)
         self.assertEqual('2', row.b)
         self.assertEqual('3', row.c)
         self.assertEqual('4', row.d)
Exemple #4
0
 def test_as_csv_header(self):
     "Csv contextmanager with header"
     p = Path(self.tmpath)
     p << 'a,b,c,d\n'
     p << '1,2,3,4'
     with p.csv(header=True) as csv:
         row = csv.next()
         self.assertEqual('1', row.a)
         self.assertEqual('2', row.b)
         self.assertEqual('3', row.c)
         self.assertEqual('4', row.d)