Skip to content

Commit 23620c7

Browse files
committed
Use title case for calendar in undate repr method
1 parent 58e2448 commit 23620c7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/undate/undate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def __repr__(self) -> str:
253253
init_opts = {k: v for k, v in self.initial_values.items() if v is not None}
254254
if self.label:
255255
init_opts["label"] = self.label
256-
init_opts["calendar"] = str(self.calendar)
256+
init_opts["calendar"] = self.calendar.value.title()
257257
init_params = []
258258
for key, val in init_opts.items():
259259
if isinstance(val, str):

tests/test_undate.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,26 @@ def test_repr(self):
3636
# repr string should provide sufficient details to initialize
3737
assert (
3838
repr(nov2022)
39-
== 'undate.Undate(year=2022, month=11, day=7, calendar="gregorian")'
39+
== 'undate.Undate(year=2022, month=11, day=7, calendar="Gregorian")'
4040
)
4141
# eval on repr string should be equivalent to the object
4242
assert eval(repr(nov2022)) == nov2022
4343
nov2022_labeled = Undate(2022, 11, 7, label="A Special Day")
4444
assert (
4545
repr(nov2022_labeled)
46-
== 'undate.Undate(year=2022, month=11, day=7, label="A Special Day", calendar="gregorian")'
46+
== 'undate.Undate(year=2022, month=11, day=7, label="A Special Day", calendar="Gregorian")'
4747
)
4848
assert eval(repr(nov2022_labeled)) == nov2022_labeled
4949
# different calendar, missing fields
5050
islamic_date = Undate(484, calendar=Calendar.ISLAMIC)
51-
assert repr(islamic_date) == 'undate.Undate(year=484, calendar="islamic")'
51+
assert repr(islamic_date) == 'undate.Undate(year=484, calendar="Islamic")'
5252
assert eval(repr(islamic_date)) == islamic_date
5353

5454
# test string values for month/day
5555
unknown_year = Undate(month="1X", day="3X")
5656
assert (
5757
repr(unknown_year)
58-
== 'undate.Undate(month="1X", day="3X", calendar="gregorian")'
58+
== 'undate.Undate(month="1X", day="3X", calendar="Gregorian")'
5959
)
6060
# unknown dates aren't equal, but string representation should match
6161
assert str(eval(repr(unknown_year))) == str(unknown_year)

0 commit comments

Comments
 (0)