Skip to content

Commit ab77ac1

Browse files
committed
Move coverage tests to their natural homes
AI disclosure: I used OpenAI Codex (GPT-5.6) to apply the requested test organization changes, review the diff, and verify formatting and the five affected tests.
1 parent 12a6716 commit ab77ac1

5 files changed

Lines changed: 35 additions & 36 deletions

File tree

src/icalendar/tests/prop/test_date_and_time.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pytest
88

9-
from icalendar import Component, vDatetime, vDDDLists, vDDDTypes, vTime
9+
from icalendar import Component, vDate, vDatetime, vDDDLists, vDDDTypes, vTime
1010
from icalendar.parser_tools import to_unicode
1111
from icalendar.prop import VPROPERTY
1212
from icalendar.timezone.tzid import is_utc
@@ -15,6 +15,11 @@
1515
from icalendar.cal.event import Event
1616

1717

18+
def test_vdate_rejects_invalid_calendar_date():
19+
with pytest.raises(ValueError, match="Wrong date format 20250230"):
20+
vDate.from_ical("20250230")
21+
22+
1823
@pytest.fixture(
1924
params=[
2025
vDatetime(datetime(2018, 1, 1, tzinfo=ZoneInfo("UTC"))),

src/icalendar/tests/prop/test_issue_698_more_coverage.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/icalendar/tests/prop/test_unit.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,21 @@ def test_prop_vCategory(self):
344344
cats = list(c)
345345
assert cats == ["APPOINTMENT", "EDUCATION"]
346346

347+
def test_vcategory_hash(self):
348+
from icalendar.prop import vCategory
349+
350+
category = vCategory(["WORK", "PERSONAL"])
351+
assert hash(category) == hash(tuple(category.cats))
352+
353+
def test_vcategory_repr(self):
354+
from icalendar.prop import vCategory
355+
356+
category = vCategory(["WORK", "PERSONAL"])
357+
category_repr = repr(category)
358+
assert category_repr == (
359+
"vCategory([vText(b'WORK'), vText(b'PERSONAL')], params=Parameters({}))"
360+
)
361+
347362
def test_prop_TypesFactory(self):
348363
from icalendar.prop import TypesFactory
349364

src/icalendar/tests/prop/test_vWeekday.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22

3+
from icalendar.error import JCalParsingError
34
from icalendar.prop import vWeekday
45

56

@@ -46,3 +47,11 @@ def test_ical_value():
4647
assert vWeekday("+2TH").ical_value == "+2TH"
4748
assert vWeekday("-1SU").ical_value == "-1SU"
4849
assert isinstance(vWeekday("MO").ical_value, str)
50+
51+
52+
def test_vweekday_rejects_invalid_jcal_value():
53+
with pytest.raises(
54+
JCalParsingError,
55+
match="The value must be a valid weekday",
56+
):
57+
vWeekday.parse_jcal_value("NOT-A-WEEKDAY")

src/icalendar/tests/test_issue_1445.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ def _line(component: Component, name: str) -> str:
3535
raise AssertionError(f"{name} not serialized in {component.to_ical()!r}")
3636

3737

38+
def test_vunknown_repr():
39+
repr_str = repr(vUnknown("a;b"))
40+
assert repr_str == "vUnknown(b'a;b')"
41+
42+
3843
# Value text exactly as it appears in the content line after the colon. Each is
3944
# an unknown value (X-MYSTERY) that must survive untouched. Mix of bare and
4045
# escaped specials, both newline spellings, and a date-time-looking value.

0 commit comments

Comments
 (0)