Skip to content

Commit f0deaa6

Browse files
author
y-p
committed
TST: str(x)/unicode(x),bytes(x)/str(x) should always work for Index,MultiIndex
1 parent b7cc302 commit f0deaa6

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

pandas/tests/test_index.py

+33
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,21 @@ def test_print_unicode_columns(self):
851851
df=pd.DataFrame({u"\u05d0":[1,2,3],"\u05d1":[4,5,6],"c":[7,8,9]})
852852
print(df.columns) # should not raise UnicodeDecodeError
853853

854+
def test_unicode_string_with_unicode(self):
855+
idx = Index(range(1000))
856+
857+
if py3compat.PY3:
858+
str(idx)
859+
else:
860+
unicode(idx)
861+
862+
def test_bytestring_with_unicode(self):
863+
idx = Index(range(1000))
864+
if py3compat.PY3:
865+
bytes(idx)
866+
else:
867+
str(idx)
868+
854869
class TestMultiIndex(unittest.TestCase):
855870

856871
def setUp(self):
@@ -1680,6 +1695,24 @@ def test_repr_with_unicode_data(self):
16801695
index=pd.DataFrame(d).set_index(["a","b"]).index
16811696
self.assertFalse("\\u" in repr(index)) # we don't want unicode-escaped
16821697

1698+
def test_unicode_string_with_unicode(self):
1699+
d={"a":[u"\u05d0",2,3],"b":[4,5,6],"c":[7,8,9]}
1700+
idx=pd.DataFrame(d).set_index(["a","b"]).index
1701+
1702+
if py3compat.PY3:
1703+
str(idx)
1704+
else:
1705+
unicode(idx)
1706+
1707+
def test_bytestring_with_unicode(self):
1708+
d={"a":[u"\u05d0",2,3],"b":[4,5,6],"c":[7,8,9]}
1709+
idx=pd.DataFrame(d).set_index(["a","b"]).index
1710+
1711+
if py3compat.PY3:
1712+
bytes(idx)
1713+
else:
1714+
str(idx)
1715+
16831716
def test_get_combined_index():
16841717
from pandas.core.index import _get_combined_index
16851718
result = _get_combined_index([])

0 commit comments

Comments
 (0)