Skip to content

Commit d04e6ae

Browse files
committed
TST: Add failing test for empty bool Categoricals
1 parent 3745576 commit d04e6ae

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pandas/tests/arrays/categorical/test_constructors.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ def test_constructor_empty(self):
4242
expected = pd.Int64Index([1, 2, 3])
4343
tm.assert_index_equal(c.categories, expected)
4444

45+
@pytest.mark.xfail
46+
def test_constructor_empty_boolean(self):
47+
# see gh-22702
48+
cat = pd.Categorical([], categories=[True, False])
49+
categories = sorted(cat.categories.tolist())
50+
assert categories == [False, True]
51+
4552
def test_constructor_tuples(self):
4653
values = np.array([(1,), (1, 2), (1,), (1, 2)], dtype=object)
4754
result = Categorical(values)

pandas/tests/indexes/test_category.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ def test_construction_with_dtype(self):
136136
result = CategoricalIndex(idx, categories=idx, ordered=True)
137137
tm.assert_index_equal(result, expected, exact=True)
138138

139+
@pytest.mark.xfail
140+
def test_construction_empty_with_bool_categories(self):
141+
# see gh-22702
142+
cat = pd.CategoricalIndex([], categories=[True, False])
143+
categories = sorted(cat.categories.tolist())
144+
assert categories == [False, True]
145+
139146
def test_construction_with_categorical_dtype(self):
140147
# construction with CategoricalDtype
141148
# GH18109

0 commit comments

Comments
 (0)