-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
35 lines (28 loc) · 1.01 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from unittest import TestCase
from Control import Control
import csv
def csvReader(file_obj, test = False):
if(test):
reader = csv.reader(file_obj, delimiter=';')
for row in reader:
print(', '.join(row))
reader = csv.reader(file_obj, delimiter=';')
return list(reader)
class PythonUnittests(TestCase):
def test_wrongFileError(self):
c = Control('asdf.csv')
self.assertRaises(TypeError, c.read)
def test_delimiter(self):
c = Control('testfile.csv')
c.delimiter = ';'
self.assertEqual(c.delimiter, ';')
def test_falseDelimiter(self):
c = Control('testfile.csv')
c.delimiter = ' '
self.assertEqual(c.delimiter, ' ')
def test_noDelimiter(self):
c = Control('testfile.csv')
self.assertIsNone(c.delimiter)
def test_contentCSV(self):
with open('testfile2.csv', newline='') as csvFile:
self.assertEqual(csvReader(csvFile),[['1', '2','3','4']])