Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
improve tests
  • Loading branch information
abast committed Feb 23, 2017
commit cd9354fc9790515b4fe602689762d89fa568dfff
5 changes: 5 additions & 0 deletions pandas/tests/io/test_packers.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ def test_string_io(self):
result = read_msgpack(s)
tm.assert_frame_equal(result, df)

df2 = df.astype({0:'category'}).set_index(0)
s = to_msgpack(None, df)
result = read_msgpack(s)
tm.assert_frame_equal(result, df)

with ensure_clean(self.path) as p:

s = df.to_msgpack()
Expand Down
12 changes: 0 additions & 12 deletions pandas/tests/msgpack/test_unpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from pandas.msgpack import Unpacker, packb, OutOfData, ExtType
import pandas.util.testing as tm
import pytest
from pandas import DataFrame, read_msgpack


class TestUnpack(tm.TestCase):
Expand Down Expand Up @@ -63,14 +62,3 @@ def _hook(self, code, data):
assert unpacker.unpack() == {'a': 123}
unpacker.feed(packb({'a': ExtType(2, b'321')}, encoding='utf-8'))
assert unpacker.unpack() == {'a': ExtType(2, b'321')}

def test_unpack_categorical_index(self):
'''dataframe with CategoricalIndex can be read and written'''
pdf = DataFrame(dict(A=[1, 1, 1, 2, 2, 2], B=[1, 2, 3, 4, 5, 6]))
pdf['A'] = pdf['A'].astype('category')
pdf.set_index('A', inplace=True)
f = BytesIO()
pdf.to_msgpack(f)
f.seek(0)
pdf2 = read_msgpack(f)
tm.assert_frame_equal(pdf, pdf2)