Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make --table invalide with multiple files. Closes #152.

  • Loading branch information...
commit 36b4c86d922903852edd43ba4b9b483402851e01 1 parent cd4be02
@onyxfish authored
View
3  csvkit/utilities/csvsql.py
@@ -35,6 +35,9 @@ def main(self):
# Ensure we're handling a list, even if it's just one file
if not isinstance(self.args.files, list):
self.args.files = [self.args.files]
+ else:
+ if self.args.table_name:
+ self.argparser.error('The --table argument is only allowed when specifying a single file.')
for f in self.args.files:
if self.args.table_name:
View
16 tests/test_utilities/test_csvjson.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
import json
-import StringIO
+from cStringIO import StringIO
import unittest
from csvkit.exceptions import NonUniqueKeyColumnException
@@ -10,7 +10,7 @@
class TestCSVJSON(unittest.TestCase):
def test_simple(self):
args = ['examples/dummy.csv']
- output_file = StringIO.StringIO()
+ output_file = StringIO()
utility = CSVJSON(args, output_file)
utility.main()
@@ -19,7 +19,7 @@ def test_simple(self):
def test_indentation(self):
args = ['-i', '4', 'examples/dummy.csv']
- output_file = StringIO.StringIO()
+ output_file = StringIO()
utility = CSVJSON(args, output_file)
utility.main()
@@ -28,7 +28,7 @@ def test_indentation(self):
def test_keying(self):
args = ['-k', 'a', 'examples/dummy.csv']
- output_file = StringIO.StringIO()
+ output_file = StringIO()
utility = CSVJSON(args, output_file)
utility.main()
@@ -37,7 +37,7 @@ def test_keying(self):
def test_duplicate_keys(self):
args = ['-k', 'a', 'examples/dummy3.csv']
- output_file = StringIO.StringIO()
+ output_file = StringIO()
utility = CSVJSON(args, output_file)
@@ -45,7 +45,7 @@ def test_duplicate_keys(self):
def test_geojson(self):
args = ['--lat', 'latitude', '--lon', 'longitude', 'examples/test_geo.csv']
- output_file = StringIO.StringIO()
+ output_file = StringIO()
utility = CSVJSON(args, output_file)
utility.main()
@@ -70,7 +70,7 @@ def test_geojson(self):
def test_geojson_with_id(self):
args = ['--lat', 'latitude', '--lon', 'longitude', '-k', 'slug', 'examples/test_geo.csv']
- output_file = StringIO.StringIO()
+ output_file = StringIO()
utility = CSVJSON(args, output_file)
utility.main()
@@ -95,7 +95,7 @@ def test_geojson_with_id(self):
def test_geojson_with_crs(self):
args = ['--lat', 'latitude', '--lon', 'longitude', '--crs', 'EPSG:4269', 'examples/test_geo.csv']
- output_file = StringIO.StringIO()
+ output_file = StringIO()
utility = CSVJSON(args, output_file)
utility.main()
View
11 tests/test_utilities/test_csvsql.py
@@ -1,9 +1,18 @@
#!/usr/bin/env python
+from cStringIO import StringIO
import unittest
from csvkit.utilities.csvsql import CSVSQL
+from tests.utils import stderr_as_stdout
class TestCSVSQL(unittest.TestCase):
- pass
+ def test_table_argument(self):
+ args = ['--table', 'foo', 'file1.csv', 'file2.csv']
+ output_file = StringIO()
+
+ utility = CSVSQL(args, output_file)
+
+ with stderr_as_stdout():
+ self.assertRaises(SystemExit, utility.main)
Please sign in to comment.
Something went wrong with that request. Please try again.