Skip to content

Commit c835dd8

Browse files
add failing case reported in pandas-dev#45417
And parameterize while we're at it.
1 parent 1ce2166 commit c835dd8

File tree

1 file changed

+38
-23
lines changed

1 file changed

+38
-23
lines changed

pandas/tests/dtypes/test_common.py

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -558,29 +558,44 @@ def test_is_float_dtype():
558558
assert com.is_float_dtype(pd.Index([1, 2.0]))
559559

560560

561-
def test_is_bool_dtype():
562-
assert not com.is_bool_dtype(int)
563-
assert not com.is_bool_dtype(str)
564-
assert not com.is_bool_dtype(pd.Series([1, 2]))
565-
assert not com.is_bool_dtype(pd.Series(["a", "b"], dtype="category"))
566-
assert not com.is_bool_dtype(np.array(["a", "b"]))
567-
assert not com.is_bool_dtype(pd.Index(["a", "b"]))
568-
assert not com.is_bool_dtype("Int64")
569-
570-
assert com.is_bool_dtype(bool)
571-
assert com.is_bool_dtype(np.bool_)
572-
assert com.is_bool_dtype(pd.Series([True, False], dtype="category"))
573-
assert com.is_bool_dtype(np.array([True, False]))
574-
assert com.is_bool_dtype(pd.Index([True, False]))
575-
576-
assert com.is_bool_dtype(pd.BooleanDtype())
577-
assert com.is_bool_dtype(pd.array([True, False, None], dtype="boolean"))
578-
assert com.is_bool_dtype("boolean")
579-
580-
581-
def test_is_bool_dtype_numpy_error():
582-
# GH39010
583-
assert not com.is_bool_dtype("0 - Name")
561+
@pytest.mark.parametrize(
562+
"value",
563+
(
564+
True,
565+
False,
566+
int,
567+
str,
568+
"Int64",
569+
"0 - Name", # GH39010
570+
pd.array(("a", "b")),
571+
pd.Index(("a", "b")),
572+
pd.Series(("a", "b"), dtype="category"),
573+
pd.Series((1, 2)),
574+
),
575+
)
576+
def test_is_bool_dtype_returns_false(value):
577+
assert com.is_bool_dtype(value) is False
578+
579+
580+
@pytest.mark.parametrize(
581+
"value",
582+
(
583+
bool,
584+
np.bool_,
585+
np.dtype(np.bool_),
586+
pd.BooleanDtype,
587+
pd.BooleanDtype(),
588+
"bool",
589+
"boolean",
590+
pd.array((True, False)),
591+
pd.Index((True, False)),
592+
pd.Series((True, False)),
593+
pd.Series((True, False), dtype="category"),
594+
pd.Series((True, False, None), dtype="boolean"),
595+
),
596+
)
597+
def test_is_bool_dtype_returns_true(value):
598+
assert com.is_bool_dtype(value) is True
584599

585600

586601
@pytest.mark.filterwarnings("ignore:'is_extension_type' is deprecated:FutureWarning")

0 commit comments

Comments
 (0)