Skip to content

Commit

Permalink
Add more explicit testing of output
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Nov 29, 2019
1 parent 2fd2b02 commit 86edb51
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
14 changes: 12 additions & 2 deletions tests/test_utilities/test_csvlook.py
Expand Up @@ -22,10 +22,20 @@ def test_launch_new_instance(self):
launch_new_instance()

def test_runs(self):
self.get_output(['examples/test_utf8.csv'])
self.assertLines(['examples/test_utf8.csv'], [
'| foo | bar | baz |',
'| --- | --- | --- |',
'| 1 | 2 | 3 |',
'| 4 | 5 | ʤ |',
])

def test_encoding(self):
self.get_output(['-e', 'latin1', 'examples/test_latin1.csv'])
self.assertLines(['-e', 'latin1', 'examples/test_latin1.csv'], [
'| a | b | c |',
'| - | - | - |',
'| 1 | 2 | 3 |',
'| 4 | 5 | © |',
])

def test_simple(self):
self.assertLines(['examples/dummy3.csv'], [
Expand Down
12 changes: 10 additions & 2 deletions tests/test_utilities/test_csvsort.py
Expand Up @@ -22,10 +22,18 @@ def test_launch_new_instance(self):
launch_new_instance()

def test_runs(self):
self.get_output(['examples/test_utf8.csv'])
self.assertRows(['examples/test_utf8.csv'], [
['foo', 'bar', 'baz'],
['1', '2', '3'],
['4', '5', 'ʤ'],
])

def test_encoding(self):
self.get_output(['-e', 'latin1', 'examples/test_latin1.csv'])
self.assertRows(['-e', 'latin1', 'examples/test_latin1.csv'], [
['a', 'b', 'c'],
['1', '2', '3'],
['4', '5', '©'],
])

def test_sort_string_reverse(self):
reader = self.get_output_as_reader(['-c', '1', '-r', 'examples/testxls_converted.csv'])
Expand Down
8 changes: 5 additions & 3 deletions tests/test_utilities/test_csvstat.py
Expand Up @@ -23,16 +23,18 @@ def test_launch_new_instance(self):
launch_new_instance()

def test_runs(self):
# Test that csvstat doesn't error on UTF-8 input.
self.get_output(['examples/test_utf8.csv'])

def test_encoding(self):
# Test that csvstat doesn't error on Latin-1 input.
self.get_output(['-e', 'latin1', 'examples/test_latin1.csv'])

def test_columns(self):
output = self.get_output(['-c', '2', 'examples/testxls_converted.csv'])
self.assertNotIn('1. "text"', output)
self.assertIn('2. "date"', output)

def test_encoding(self):
self.get_output(['-e', 'latin1', 'examples/test_latin1.csv'])

def test_linenumbers(self):
output = self.get_output(['-c', '2', '--linenumbers', 'examples/dummy.csv'])
self.assertNotIn('1. "a"', output)
Expand Down
1 change: 1 addition & 0 deletions tests/test_utilities/test_sql2csv.py
Expand Up @@ -56,6 +56,7 @@ def csvsql(self, csv_file, db=None):
return text.strip()

def test_encoding(self):
# Test that csvstat doesn't error on Latin-1 input.
self.get_output(['-e', 'latin1', 'examples/test.sql'])

def test_query(self):
Expand Down

0 comments on commit 86edb51

Please sign in to comment.