Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

7:red

  • Loading branch information...
commit b06f1ef41cf4294e2b72e3a514259b821fbbbedb 1 parent 38a86d0
@nibrahim authored
Showing with 19 additions and 0 deletions.
  1. +2 −0  pycsv/tests/error.csv
  2. +17 −0 pycsv/tests/test_pycsv.py
View
2  pycsv/tests/error.csv
@@ -0,0 +1,2 @@
+"Something", "Else", Going, On, ",
+What, Else,"Is going", On, here
View
17 pycsv/tests/test_pycsv.py
@@ -1,3 +1,5 @@
+import py
+
def test_import(setup):
"Try importing the module"
import pycsv
@@ -56,3 +58,18 @@ def cell_callback(cell, data):
csvfile.parse(cell_callback, row_callback, tmp)
assert tmp.rows == [["Header0", "Header1", "Header2"], ["Data00", "Data01", "Data02"], ["Data10", "Data11", "Data12"]]
+
+def test_csvfile_bad_file(setup):
+ "Checks to see if we raise an exception if the file we're parsing is broken"
+ import pycsv
+
+ def cell_callback(cell, data):
+ pass
+
+ with open("tests/error.csv") as f:
+ csvfile = pycsv.CSVFile(f)
+ with py.test.raises(pycsv.ParseError):
+ csvfile.parse(cell_callback, None, None)
+
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.