From b715f107f11a999c9cbdba00b82ddd8740b4adb3 Mon Sep 17 00:00:00 2001 From: gfyoung Date: Mon, 31 Dec 2018 02:20:40 -0800 Subject: [PATCH] MAINT: Use context manager in test_c_parser_only Specifically, use context manager for pytest.raises. xref gh-24332. --- pandas/tests/io/parser/test_c_parser_only.py | 38 ++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/pandas/tests/io/parser/test_c_parser_only.py b/pandas/tests/io/parser/test_c_parser_only.py index 76a04a4161625..a405617b4132d 100644 --- a/pandas/tests/io/parser/test_c_parser_only.py +++ b/pandas/tests/io/parser/test_c_parser_only.py @@ -111,7 +111,24 @@ def test_dtype_and_names_error(c_parser_only): names=["a", "b"], dtype={"a": np.int32}) -def test_unsupported_dtype(c_parser_only): +@pytest.mark.parametrize("match,kwargs", [ + # For each of these cases, all of the dtypes are valid, just unsupported. + (("the dtype datetime64 is not supported for parsing, " + "pass this column using parse_dates instead"), + dict(dtype={"A": "datetime64", "B": "float64"})), + + (("the dtype datetime64 is not supported for parsing, " + "pass this column using parse_dates instead"), + dict(dtype={"A": "datetime64", "B": "float64"}, + parse_dates=["B"])), + + ("the dtype timedelta64 is not supported for parsing", + dict(dtype={"A": "timedelta64", "B": "float64"})), + + ("the dtype