Skip to content

Commit 85a9f8c

Browse files
authored
TST: test addl feather dtypes (#16004)
1 parent 2d9451d commit 85a9f8c

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

pandas/tests/io/test_feather.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,18 @@
88
from pandas.io.feather_format import to_feather, read_feather
99

1010
from feather import FeatherError
11-
import pandas.util.testing as tm
1211
from pandas.util.testing import assert_frame_equal, ensure_clean
1312

1413

15-
class TestFeather(tm.TestCase):
16-
17-
def setUp(self):
18-
pass
14+
class TestFeather(object):
1915

2016
def check_error_on_write(self, df, exc):
2117
# check that we are raising the exception
2218
# on writing
2319

24-
def f():
20+
with pytest.raises(exc):
2521
with ensure_clean() as path:
2622
to_feather(df, path)
27-
self.assertRaises(exc, f)
2823

2924
def check_round_trip(self, df):
3025

@@ -41,17 +36,21 @@ def test_error(self):
4136

4237
def test_basic(self):
4338

44-
df = pd.DataFrame({'a': list('abc'),
45-
'b': list(range(1, 4)),
46-
'c': np.arange(3, 6).astype('u1'),
47-
'd': np.arange(4.0, 7.0, dtype='float64'),
48-
'e': [True, False, True],
49-
'f': pd.Categorical(list('abc')),
50-
'g': pd.date_range('20130101', periods=3),
51-
'h': pd.date_range('20130101', periods=3,
52-
tz='US/Eastern'),
53-
'i': pd.date_range('20130101', periods=3,
54-
freq='ns')})
39+
df = pd.DataFrame({'string': list('abc'),
40+
'int': list(range(1, 4)),
41+
'uint': np.arange(3, 6).astype('u1'),
42+
'float': np.arange(4.0, 7.0, dtype='float64'),
43+
'float_with_null': [1., np.nan, 3],
44+
'bool': [True, False, True],
45+
'bool_with_null': [True, np.nan, False],
46+
'cat': pd.Categorical(list('abc')),
47+
'dt': pd.date_range('20130101', periods=3),
48+
'dttz': pd.date_range('20130101', periods=3,
49+
tz='US/Eastern'),
50+
'dt_with_null': [pd.Timestamp('20130101'), pd.NaT,
51+
pd.Timestamp('20130103')],
52+
'dtns': pd.date_range('20130101', periods=3,
53+
freq='ns')})
5554

5655
self.check_round_trip(df)
5756

@@ -80,6 +79,9 @@ def test_unsupported(self):
8079
df = pd.DataFrame({'a': pd.period_range('2013', freq='M', periods=3)})
8180
self.check_error_on_write(df, ValueError)
8281

82+
df = pd.DataFrame({'a': pd.timedelta_range('1 day', periods=3)})
83+
self.check_error_on_write(df, FeatherError)
84+
8385
# non-strings
8486
df = pd.DataFrame({'a': ['a', 1, 2.0]})
8587
self.check_error_on_write(df, ValueError)

0 commit comments

Comments
 (0)