summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_io.py
diff options
context:
space:
mode:
authorRoss Barnowski <rossbar@berkeley.edu>2022-01-10 12:15:02 -0800
committerSebastian Berg <sebastian@sipsolutions.net>2022-01-14 20:07:07 -0600
commit942d4f8ab095f152f5e59e43cada49d3d15839d0 (patch)
treeb06267c4ff702f7e0bad0d82adb9a25f64eef365 /numpy/lib/tests/test_io.py
parentbbf14c01022023f0be0b3d25af2d315a6e42598e (diff)
downloadnumpy-942d4f8ab095f152f5e59e43cada49d3d15839d0.tar.gz
Add test to check quoting support disabled by default.
Diffstat (limited to 'numpy/lib/tests/test_io.py')
-rw-r--r--numpy/lib/tests/test_io.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index 97d8f5b14..a0bc2e135 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -3161,3 +3161,19 @@ def test_loadtxt_quoted_field(q):
# Test quote param default
res = np.loadtxt(txt, dtype=dtype, delimiter=",", quotechar=q)
assert_array_equal(res, expected)
+
+
+def test_loadtxt_quote_support_default():
+ """Support for quoted fields is disabled by default."""
+ txt = TextIO('"lat,long", 45, 30\n')
+ dtype = np.dtype([('f0', 'U24'), ('f1', np.float64), ('f2', np.float64)])
+
+ with pytest.raises(ValueError, match="the number of columns changed"):
+ np.loadtxt(txt, dtype=dtype, delimiter=",")
+
+ # Enable quoting support with non-None value for quotechar param
+ txt.seek(0)
+ expected = np.array([("lat,long", 45., 30.)], dtype=dtype)
+
+ res = np.loadtxt(txt, dtype=dtype, delimiter=",", quotechar='"')
+ assert_array_equal(res, expected)