Skip to content

Commit f6bbbdc

Browse files
author
y-p
committed
Add test to catch broken console_encode()
1 parent af3e13c commit f6bbbdc

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

pandas/tests/test_common.py

+8-13
Original file line numberDiff line numberDiff line change
@@ -309,22 +309,17 @@ def test_2d_float32(self):
309309
tm.assert_almost_equal(result, expected)
310310

311311
def test_console_encode(self):
312-
import sys
313-
314-
if py3compat.PY3 or sys.stdin.encoding is None:
312+
"""
313+
On Python 2, if sys.stdin.encoding is None (IPython with zmq frontend)
314+
common.console_encode should encode things as utf-8.
315+
"""
316+
if py3compat.PY3:
315317
raise nose.SkipTest
316318

317-
# stub test
318-
# need to mock-out sys.stdin.encoding=None for real test
319-
result = com.console_encode(u"\u05d0")
320-
try:
321-
expected = u"\u05d0".encode(sys.stdin.encoding)
322-
323-
# lot of console encodings, ISO-8869-1, cp850, etc. won't encode
324-
# this character
319+
with tm.stdin_encoding(encoding=None):
320+
result = com.console_encode(u"\u05d0")
321+
expected = u"\u05d0".encode('utf-8')
325322
self.assertEqual(result, expected)
326-
except UnicodeEncodeError:
327-
pass
328323

329324

330325
if __name__ == '__main__':

0 commit comments

Comments
 (0)