Skip to content

Commit cd9354f

Browse files
committed
improve tests
1 parent 7895c16 commit cd9354f

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

pandas/tests/io/test_packers.py

+5
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ def test_string_io(self):
123123
result = read_msgpack(s)
124124
tm.assert_frame_equal(result, df)
125125

126+
df2 = df.astype({0:'category'}).set_index(0)
127+
s = to_msgpack(None, df)
128+
result = read_msgpack(s)
129+
tm.assert_frame_equal(result, df)
130+
126131
with ensure_clean(self.path) as p:
127132

128133
s = df.to_msgpack()

pandas/tests/msgpack/test_unpack.py

-12
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from pandas.msgpack import Unpacker, packb, OutOfData, ExtType
44
import pandas.util.testing as tm
55
import pytest
6-
from pandas import DataFrame, read_msgpack
76

87

98
class TestUnpack(tm.TestCase):
@@ -63,14 +62,3 @@ def _hook(self, code, data):
6362
assert unpacker.unpack() == {'a': 123}
6463
unpacker.feed(packb({'a': ExtType(2, b'321')}, encoding='utf-8'))
6564
assert unpacker.unpack() == {'a': ExtType(2, b'321')}
66-
67-
def test_unpack_categorical_index(self):
68-
'''dataframe with CategoricalIndex can be read and written'''
69-
pdf = DataFrame(dict(A=[1, 1, 1, 2, 2, 2], B=[1, 2, 3, 4, 5, 6]))
70-
pdf['A'] = pdf['A'].astype('category')
71-
pdf.set_index('A', inplace=True)
72-
f = BytesIO()
73-
pdf.to_msgpack(f)
74-
f.seek(0)
75-
pdf2 = read_msgpack(f)
76-
tm.assert_frame_equal(pdf, pdf2)

0 commit comments

Comments
 (0)