From 2e242310b4a136daec79cc085228800426e23804 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler <61934744+phofl@users.noreply.github.com> Date: Sun, 26 Nov 2023 18:27:50 +0100 Subject: [PATCH] Adjust tests in tseries folder for new string option --- pandas/tests/tseries/frequencies/test_inference.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pandas/tests/tseries/frequencies/test_inference.py b/pandas/tests/tseries/frequencies/test_inference.py index ee8f161858b2b..75528a8b99c4d 100644 --- a/pandas/tests/tseries/frequencies/test_inference.py +++ b/pandas/tests/tseries/frequencies/test_inference.py @@ -431,12 +431,18 @@ def test_series_invalid_type(end): frequencies.infer_freq(s) -def test_series_inconvertible_string(): +def test_series_inconvertible_string(using_infer_string): # see gh-6407 - msg = "Unknown datetime string format" + if using_infer_string: + msg = "cannot infer freq from" - with pytest.raises(ValueError, match=msg): - frequencies.infer_freq(Series(["foo", "bar"])) + with pytest.raises(TypeError, match=msg): + frequencies.infer_freq(Series(["foo", "bar"])) + else: + msg = "Unknown datetime string format" + + with pytest.raises(ValueError, match=msg): + frequencies.infer_freq(Series(["foo", "bar"])) @pytest.mark.parametrize("freq", [None, "ms"])