diff --git a/news/876.bugfix b/news/876.bugfix new file mode 100644 index 000000000..17fb780fb --- /dev/null +++ b/news/876.bugfix @@ -0,0 +1 @@ +Fixed :attr:`vSkip.ical_value ` returning ``vSkip.OMIT`` instead of the :rfc:`7529` value ``OMIT``. I used Claude Opus 5.5 to help locate the bug. @jakkoyang diff --git a/src/icalendar/prop/recur/skip.py b/src/icalendar/prop/recur/skip.py index 157cafdc9..805d121d8 100644 --- a/src/icalendar/prop/recur/skip.py +++ b/src/icalendar/prop/recur/skip.py @@ -45,6 +45,19 @@ class vSkip(vText, Enum): def __repr__(self): return f"{self.__class__.__name__}({self._name_!r})" + @property + def ical_value(self) -> str: + """The :rfc:`7529` SKIP value, for example ``OMIT``. + + Example: + .. code-block:: pycon + + >>> from icalendar import vSkip + >>> vSkip.FORWARD.ical_value + 'FORWARD' + """ + return self.name + @classmethod def parse_jcal_value(cls, value: Any) -> Self: """Parse a jCal value for vSkip. diff --git a/src/icalendar/tests/prop/test_vSkip.py b/src/icalendar/tests/prop/test_vSkip.py new file mode 100644 index 000000000..a2b8ea8ed --- /dev/null +++ b/src/icalendar/tests/prop/test_vSkip.py @@ -0,0 +1,24 @@ +"""Tests for vSkip.ical_value (issue #876).""" + +import pytest + +from icalendar.prop import vSkip + + +@pytest.mark.parametrize( + ("skip", "expected"), + [ + (vSkip.OMIT, "OMIT"), + (vSkip.FORWARD, "FORWARD"), + (vSkip.BACKWARD, "BACKWARD"), + ], +) +def test_ical_value_is_the_rfc_7529_token(skip, expected): + """ical_value returns the RFC 7529 SKIP token, not the enum name.""" + assert skip.ical_value == expected + + +@pytest.mark.parametrize("skip", list(vSkip)) +def test_ical_value_is_a_plain_str(skip): + """ical_value is a plain str, not a vText (isinstance would accept both).""" + assert type(skip.ical_value) is str