Skip to content

Commit ffed8a0

Browse files
author
Daniel Saxton
committed
Add CategoricalIndex test
1 parent 952114f commit ffed8a0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pandas/tests/extension/test_categorical.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import pytest
2020

2121
import pandas as pd
22-
from pandas import Categorical
22+
from pandas import Categorical, CategoricalIndex
2323
from pandas.api.types import CategoricalDtype
2424
from pandas.tests.extension import base
2525
import pandas.util.testing as tm
@@ -197,9 +197,10 @@ def test_searchsorted(self, data_for_sorting):
197197

198198

199199
class TestCasting(base.BaseCastingTests):
200+
@pytest.mark.parametrize("cls", [Categorical, CategoricalIndex])
200201
@pytest.mark.parametrize("value", [np.nan, -np.inf, np.inf])
201-
def test_cast_nan_to_int(self, value):
202-
s = pd.Series([0, 1, value], dtype="category")
202+
def test_cast_nan_to_int(self, cls, value):
203+
s = cls([0, 1, value])
203204

204205
with pytest.raises(ValueError):
205206
s.astype(int)

0 commit comments

Comments
 (0)