Skip to content

Commit

Permalink
Merge branch 'master' into jennifersmith-355_streaming_json_documents
Browse files Browse the repository at this point in the history
  • Loading branch information
onyxfish committed Nov 22, 2014
2 parents 3d69836 + 429c5a3 commit f9f39e6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
48 changes: 24 additions & 24 deletions tests/test_utilities/test_csvlook.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,50 @@
class TestCSVLook(unittest.TestCase):
def test_simple(self):
args = ['examples/dummy3.csv']
output_file = six.BytesIO()
output_file = six.StringIO()
utility = CSVLook(args, output_file)

utility.main()

input_file = six.BytesIO(output_file.getvalue())
input_file = six.StringIO(output_file.getvalue())

self.assertEqual(next(input_file), b'|----+---+----|\n')
self.assertEqual(next(input_file), b'| a | b | c |\n')
self.assertEqual(next(input_file), b'|----+---+----|\n')
self.assertEqual(next(input_file), b'| 1 | 2 | 3 |\n')
self.assertEqual(next(input_file), b'| 1 | 4 | 5 |\n')
self.assertEqual(next(input_file), b'|----+---+----|\n')
self.assertEqual(next(input_file), '|----+---+----|\n')
self.assertEqual(next(input_file), '| a | b | c |\n')
self.assertEqual(next(input_file), '|----+---+----|\n')
self.assertEqual(next(input_file), '| 1 | 2 | 3 |\n')
self.assertEqual(next(input_file), '| 1 | 4 | 5 |\n')
self.assertEqual(next(input_file), '|----+---+----|\n')

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

utility.main()

input_file = six.BytesIO(output_file.getvalue())
input_file = six.StringIO(output_file.getvalue())

self.assertEqual(next(input_file), b'|----------+---------+----------|\n')
self.assertEqual(next(input_file), b'| column1 | column2 | column3 |\n')
self.assertEqual(next(input_file), b'|----------+---------+----------|\n')
self.assertEqual(next(input_file), b'| 1 | 2 | 3 |\n')
self.assertEqual(next(input_file), b'| 4 | 5 | 6 |\n')
self.assertEqual(next(input_file), b'|----------+---------+----------|\n')
self.assertEqual(next(input_file), '|----------+---------+----------|\n')
self.assertEqual(next(input_file), '| column1 | column2 | column3 |\n')
self.assertEqual(next(input_file), '|----------+---------+----------|\n')
self.assertEqual(next(input_file), '| 1 | 2 | 3 |\n')
self.assertEqual(next(input_file), '| 4 | 5 | 6 |\n')
self.assertEqual(next(input_file), '|----------+---------+----------|\n')

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

output_file = six.BytesIO()
output_file = six.StringIO()
utility = CSVLook(args, output_file)

utility.main()

input_file = six.BytesIO(output_file.getvalue())
input_file = six.StringIO(output_file.getvalue())

self.assertEqual(next(input_file), b'|----+---+----|\n')
self.assertEqual(next(input_file), b'| a | b | c |\n')
self.assertEqual(next(input_file), b'|----+---+----|\n')
self.assertEqual(next(input_file), b'| 1 | 2 | 3 |\n')
self.assertEqual(next(input_file), b'| 4 | 5 | \xca\xa4 |\n')
self.assertEqual(next(input_file), b'|----+---+----|\n')
self.assertEqual(next(input_file), '|----+---+----|\n')
self.assertEqual(next(input_file), '| a | b | c |\n')
self.assertEqual(next(input_file), '|----+---+----|\n')
self.assertEqual(next(input_file), '| 1 | 2 | 3 |\n')
self.assertEqual(next(input_file), u'| 4 | 5 | ʤ |\n')
self.assertEqual(next(input_file), '|----+---+----|\n')

12 changes: 6 additions & 6 deletions tests/test_utilities/test_csvstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,38 @@
class TestCSVStat(unittest.TestCase):
def test_runs(self):
args = ['examples/test_utf8.csv']
output_file = six.BytesIO()
output_file = six.StringIO()

utility = CSVStat(args, output_file)
utility.main()

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

utility = CSVStat(args, output_file)
utility.main()

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

utility = CSVStat(args, output_file)
utility.main()

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

self.assertFalse('column1' in stats)
self.assertTrue('column2' in stats)

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

utility = CSVStat(args, output_file)
utility.main()

stats = output_file.getvalue()

self.assertEqual(stats, b'Row count: 1\n')
self.assertEqual(stats, 'Row count: 1\n')

0 comments on commit f9f39e6

Please sign in to comment.