summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_io.py
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2019-04-26 14:47:48 -0700
committerGitHub <noreply@github.com>2019-04-26 14:47:48 -0700
commitbf1e9b747db5b0ccee6fe58c92a4d0adee2c2063 (patch)
tree5ed749e1cdcada34dde094dfb271660908e52814 /numpy/lib/tests/test_io.py
parent5d248def4ebb0cbb96c4aebe0e2f17b9914119b1 (diff)
parent59a521ee07693cc5c58d68987691df4bcc9e48ff (diff)
downloadnumpy-bf1e9b747db5b0ccee6fe58c92a4d0adee2c2063.tar.gz
Merge pull request #13409 from seberg/fix-unicode-fmt-savetxt
BUG: (py2 only) fix unicode support for savetxt fmt string
Diffstat (limited to 'numpy/lib/tests/test_io.py')
-rw-r--r--numpy/lib/tests/test_io.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index 9d6111e37..c6193d79f 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -561,6 +561,19 @@ class TestSaveTxt(object):
s.seek(0)
assert_equal(s.read(), utf8 + '\n')
+ @pytest.mark.parametrize("fmt", [u"%f", b"%f"])
+ @pytest.mark.parametrize("iotype", [StringIO, BytesIO])
+ def test_unicode_and_bytes_fmt(self, fmt, iotype):
+ # string type of fmt should not matter, see also gh-4053
+ a = np.array([1.])
+ s = iotype()
+ np.savetxt(s, a, fmt=fmt)
+ s.seek(0)
+ if iotype is StringIO:
+ assert_equal(s.read(), u"%f\n" % 1.)
+ else:
+ assert_equal(s.read(), b"%f\n" % 1.)
+
class LoadTxtBase(object):
def check_compressed(self, fopen, suffixes):