diff options
author | Ross Barnowski <rossbar@berkeley.edu> | 2022-01-10 12:57:42 -0800 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2022-01-14 20:07:07 -0600 |
commit | 1489805af8ec0f2b27e4f7439bdc4e48acfdaa6a (patch) | |
tree | 301aa1f7b92bfedc7705f50855a4d93f52202727 /numpy/lib/tests/test_io.py | |
parent | ff5eb6406a80d7858b93516f96f3e76f57236eb3 (diff) | |
download | numpy-1489805af8ec0f2b27e4f7439bdc4e48acfdaa6a.tar.gz |
Add tests for empty quotes and escaped quotechars.
Diffstat (limited to 'numpy/lib/tests/test_io.py')
-rw-r--r-- | numpy/lib/tests/test_io.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index 32beddfdb..e218ba657 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -3229,3 +3229,17 @@ def test_loadtxt_structured_dtype_with_quotes(): ) res = np.loadtxt(data, dtype=dtype, delimiter=";", quotechar="'") assert_array_equal(res, expected) + + +def test_loadtxt_quoted_field_is_not_empty(): + txt = StringIO('1\n\n"4"\n""') + expected = np.array(["1", "4", ""], dtype="U1") + res = np.loadtxt(txt, delimiter=",", dtype="U1", quotechar='"') + assert_equal(res, expected) + + +def test_loadtxt_consecutive_quotechar_escaped(): + txt = TextIO('"Hello, my name is ""Monty""!"') + expected = np.array('Hello, my name is "Monty"!', dtype="U40") + res = np.loadtxt(txt, dtype="U40", delimiter=",", quotechar='"') + assert_equal(res, expected) |