Permalink
Browse files

add tests for --sheet option on in2csv

  • Loading branch information...
1 parent fbdce4a commit 2f2d3497ea035516a50f2744831c2caa8832e495 @jpmckinney jpmckinney committed Jan 8, 2013
Showing with 22 additions and 0 deletions.
  1. +7 −0 tests/test_convert/test_xls.py
  2. +6 −0 tests/test_convert/test_xlsx.py
  3. +9 −0 tests/test_utilities/test_in2csv.py
@@ -85,3 +85,10 @@ def test_xls(self):
with open('examples/testxls_converted.csv', 'r') as f:
self.assertEquals(f.read(), output)
+
+ def test_xls_with_sheet(self):
+ with open('examples/sheets.xls', 'rb') as f:
+ output = xls.xls2csv(f, sheet='Sheet2')
+
+ with open('examples/sheetsxls_converted.csv', 'r') as f:
+ self.assertEquals(f.read(), output)
@@ -12,3 +12,9 @@ def test_xlsx(self):
with open('examples/testxlsx_converted.csv', 'r') as f:
self.assertEquals(f.read(), output)
+ def test_xlsx_with_sheet(self):
+ with open('examples/sheets.xlsx', 'rb') as f:
+ output = xlsx.xlsx2csv(f, None, sheet='Sheet2')
+
+ with open('examples/sheetsxlsx_converted.csv', 'r') as f:
+ self.assertEquals(f.read(), output)
@@ -16,3 +16,12 @@ def test_convert_xls(self):
target_output = open('examples/testxls_converted.csv', 'r').read()
self.assertEqual(output_file.getvalue(), target_output)
+ def test_convert_specific_xls_sheet(self):
+ args = ['-f', 'xls', '--sheet', 'Sheet2', 'examples/sheets.xls']
+ output_file = StringIO.StringIO()
+
+ utility = In2CSV(args, output_file)
+ utility.main()
+
+ target_output = open('examples/sheetsxls_converted.csv', 'r').read()
+ self.assertEqual(output_file.getvalue(), target_output)

0 comments on commit 2f2d349

Please sign in to comment.