diff --git a/arrow/arrow.py b/arrow/arrow.py index eecf23266..d9fc87f89 100644 --- a/arrow/arrow.py +++ b/arrow/arrow.py @@ -1855,7 +1855,7 @@ def _get_frames(cls, name: _T_FRAMES) -> Tuple[str, str, int]: """ if name in cls._ATTRS: return name, f"{name}s", 1 - elif name[-1] == "s" and name[:-1] in cls._ATTRS: + elif name.endswith("s") and name[:-1] in cls._ATTRS: return name[:-1], name, 1 elif name in ["week", "weeks"]: return "week", "weeks", 1 diff --git a/tests/test_arrow.py b/tests/test_arrow.py index b595e4e21..89ff29b6d 100644 --- a/tests/test_arrow.py +++ b/tests/test_arrow.py @@ -1084,11 +1084,12 @@ def test_imaginary(self): assert len(pacific_range) == len(set(pacific_range)) assert len(utc_range) == len(set(utc_range)) - def test_unsupported(self): - with pytest.raises(ValueError): + @pytest.mark.parametrize("frame", ["abc", ""]) + def test_unsupported(self, frame): + with pytest.raises(ValueError, match="not supported. Supported frames:"): next( arrow.Arrow.range( - "abc", datetime.now(timezone.utc), datetime.now(timezone.utc) + frame, datetime.now(timezone.utc), datetime.now(timezone.utc) ) ) @@ -1631,9 +1632,10 @@ def test_exact(self): @pytest.mark.usefixtures("time_2013_02_15") class TestArrowSpan: - def test_span_attribute(self): - with pytest.raises(ValueError): - self.arrow.span("span") + @pytest.mark.parametrize("frame", ["span", ""]) + def test_span_attribute(self, frame): + with pytest.raises(ValueError, match="not supported. Supported frames:"): + self.arrow.span(frame) def test_span_year(self): floor, ceil = self.arrow.span("year")