Skip to content

Commit 429c5a3

Browse files
committed
Fix tests for csvlook and csvstat. Closes wireservice#346. Closes wireservice#363. (Again.)
1 parent 4548bcd commit 429c5a3

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

tests/test_utilities/test_csvlook.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,50 +13,50 @@
1313
class TestCSVLook(unittest.TestCase):
1414
def test_simple(self):
1515
args = ['examples/dummy3.csv']
16-
output_file = six.BytesIO()
16+
output_file = six.StringIO()
1717
utility = CSVLook(args, output_file)
1818

1919
utility.main()
2020

21-
input_file = six.BytesIO(output_file.getvalue())
21+
input_file = six.StringIO(output_file.getvalue())
2222

23-
self.assertEqual(next(input_file), b'|----+---+----|\n')
24-
self.assertEqual(next(input_file), b'| a | b | c |\n')
25-
self.assertEqual(next(input_file), b'|----+---+----|\n')
26-
self.assertEqual(next(input_file), b'| 1 | 2 | 3 |\n')
27-
self.assertEqual(next(input_file), b'| 1 | 4 | 5 |\n')
28-
self.assertEqual(next(input_file), b'|----+---+----|\n')
23+
self.assertEqual(next(input_file), '|----+---+----|\n')
24+
self.assertEqual(next(input_file), '| a | b | c |\n')
25+
self.assertEqual(next(input_file), '|----+---+----|\n')
26+
self.assertEqual(next(input_file), '| 1 | 2 | 3 |\n')
27+
self.assertEqual(next(input_file), '| 1 | 4 | 5 |\n')
28+
self.assertEqual(next(input_file), '|----+---+----|\n')
2929

3030
def test_no_header(self):
3131
args = ['--no-header-row', 'examples/no_header_row3.csv']
32-
output_file = six.BytesIO()
32+
output_file = six.StringIO()
3333
utility = CSVLook(args, output_file)
3434

3535
utility.main()
3636

37-
input_file = six.BytesIO(output_file.getvalue())
37+
input_file = six.StringIO(output_file.getvalue())
3838

39-
self.assertEqual(next(input_file), b'|----------+---------+----------|\n')
40-
self.assertEqual(next(input_file), b'| column1 | column2 | column3 |\n')
41-
self.assertEqual(next(input_file), b'|----------+---------+----------|\n')
42-
self.assertEqual(next(input_file), b'| 1 | 2 | 3 |\n')
43-
self.assertEqual(next(input_file), b'| 4 | 5 | 6 |\n')
44-
self.assertEqual(next(input_file), b'|----------+---------+----------|\n')
39+
self.assertEqual(next(input_file), '|----------+---------+----------|\n')
40+
self.assertEqual(next(input_file), '| column1 | column2 | column3 |\n')
41+
self.assertEqual(next(input_file), '|----------+---------+----------|\n')
42+
self.assertEqual(next(input_file), '| 1 | 2 | 3 |\n')
43+
self.assertEqual(next(input_file), '| 4 | 5 | 6 |\n')
44+
self.assertEqual(next(input_file), '|----------+---------+----------|\n')
4545

4646
def test_unicode(self):
4747
args = ['examples/test_utf8.csv']
4848

49-
output_file = six.BytesIO()
49+
output_file = six.StringIO()
5050
utility = CSVLook(args, output_file)
5151

5252
utility.main()
5353

54-
input_file = six.BytesIO(output_file.getvalue())
54+
input_file = six.StringIO(output_file.getvalue())
5555

56-
self.assertEqual(next(input_file), b'|----+---+----|\n')
57-
self.assertEqual(next(input_file), b'| a | b | c |\n')
58-
self.assertEqual(next(input_file), b'|----+---+----|\n')
59-
self.assertEqual(next(input_file), b'| 1 | 2 | 3 |\n')
60-
self.assertEqual(next(input_file), b'| 4 | 5 | \xca\xa4 |\n')
61-
self.assertEqual(next(input_file), b'|----+---+----|\n')
56+
self.assertEqual(next(input_file), '|----+---+----|\n')
57+
self.assertEqual(next(input_file), '| a | b | c |\n')
58+
self.assertEqual(next(input_file), '|----+---+----|\n')
59+
self.assertEqual(next(input_file), '| 1 | 2 | 3 |\n')
60+
self.assertEqual(next(input_file), u'| 4 | 5 | ʤ |\n')
61+
self.assertEqual(next(input_file), '|----+---+----|\n')
6262

tests/test_utilities/test_csvstat.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,38 @@
1212
class TestCSVStat(unittest.TestCase):
1313
def test_runs(self):
1414
args = ['examples/test_utf8.csv']
15-
output_file = six.BytesIO()
15+
output_file = six.StringIO()
1616

1717
utility = CSVStat(args, output_file)
1818
utility.main()
1919

2020
def test_encoding(self):
2121
args = ['-e', 'latin1', 'examples/test_latin1.csv']
22-
output_file = six.BytesIO()
22+
output_file = six.StringIO()
2323

2424
utility = CSVStat(args, output_file)
2525
utility.main()
2626

2727
def test_no_header_row(self):
2828
args = ['-H', '-c', '2', 'examples/no_header_row.csv']
29-
output_file = six.BytesIO()
29+
output_file = six.StringIO()
3030

3131
utility = CSVStat(args, output_file)
3232
utility.main()
3333

34-
stats = output_file.getvalue().decode('utf-8')
34+
stats = output_file.getvalue()
3535

3636
self.assertFalse('column1' in stats)
3737
self.assertTrue('column2' in stats)
3838

3939
def test_count_only(self):
4040
args = ['--count', 'examples/dummy.csv']
41-
output_file = six.BytesIO()
41+
output_file = six.StringIO()
4242

4343
utility = CSVStat(args, output_file)
4444
utility.main()
4545

4646
stats = output_file.getvalue()
4747

48-
self.assertEqual(stats, b'Row count: 1\n')
48+
self.assertEqual(stats, 'Row count: 1\n')
4949

0 commit comments

Comments
 (0)