Skip to content

Commit c22da50

Browse files
author
y-p
committed
TST: str(x)/unicode(x),bytes(x)/str(x) should always work if x is a df/series containing unicode
1 parent 695aa06 commit c22da50

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

pandas/tests/test_frame.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from pandas.util.testing import (assert_almost_equal,
2828
assert_series_equal,
2929
assert_frame_equal)
30+
from pandas.util import py3compat
3031

3132
import pandas.util.testing as tm
3233
import pandas.lib as lib
@@ -2916,6 +2917,21 @@ def test_repr_unicode(self):
29162917
result = repr(df)
29172918
self.assertEqual(result.split('\n')[0].rstrip(), ex_top)
29182919

2920+
def test_unicode_string_with_unicode(self):
2921+
df = DataFrame({'A': [u"\u05d0"]})
2922+
2923+
if py3compat.PY3:
2924+
str(df)
2925+
else:
2926+
unicode(df)
2927+
2928+
def test_bytestring_with_unicode(self):
2929+
df = DataFrame({'A': [u"\u05d0"]})
2930+
if py3compat.PY3:
2931+
bytes(df)
2932+
else:
2933+
str(df)
2934+
29192935
def test_very_wide_info_repr(self):
29202936
df = DataFrame(np.random.randn(10, 20),
29212937
columns=[tm.rands(10) for _ in xrange(20)])

pandas/tests/test_series.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,22 @@ def test_repr_should_return_str (self):
10831083
df=Series(data,index=index1)
10841084
self.assertTrue(type(df.__repr__() == str)) # both py2 / 3
10851085

1086+
1087+
def test_unicode_string_with_unicode(self):
1088+
df = Series([u"\u05d0"],name=u"\u05d1")
1089+
if py3compat.PY3:
1090+
str(df)
1091+
else:
1092+
unicode(df)
1093+
1094+
def test_bytestring_with_unicode(self):
1095+
df = Series([u"\u05d0"],name=u"\u05d1")
1096+
if py3compat.PY3:
1097+
bytes(df)
1098+
else:
1099+
str(df)
1100+
1101+
10861102
def test_timeseries_repr_object_dtype(self):
10871103
index = Index([datetime(2000, 1, 1) + timedelta(i)
10881104
for i in range(1000)], dtype=object)

0 commit comments

Comments
 (0)