New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-35078:Allow customization of CSS class name of a month in calendar module #10137
Conversation
Tests could be added for the new change at cpython/Lib/test/test_calendar.py Line 561 in 4e3a53b
self.assertIn('class="month"', local_month)
cal.cssclass_month_head = "text-center month"
local_month = cal.formatmonthname(2010, 10)
self.assertIn('class="text-center month"', local_month) A NEWS entry might help with the change. Thanks for the PR :) |
I would suggest adding the actual change done to the NEWS entry in addition to the current text like
The month's head CSS class in :class:`calendar.LocaleHTMLCalendar`
is now customizable with attribute ``cssclass_month_head``.
It's more of a personal opinion and would leave it to the reviewer to consider the wording. Other than that LGTM. Thanks for your contribution :)
The code looks good to me. There's no additional test for However there's no test for the changed method Furthermore the NEWS entry is misleading (and as Serhiy noted on bpo: "We don't usually do pure refactoring changes"). I'd use something like: "Refactor If you could add a test for |
Sure @doerwalter |
There's still a test missing for the changed - def test_locale_html_calendar_custom_css_class(self):
+ def test_locale_html_calendar_custom_css_class_month_name(self):
try:
cal = calendar.LocaleHTMLCalendar(locale='')
local_month = cal.formatmonthname(2010, 10, 10)
@@ -576,6 +576,19 @@ class CalendarTestCase(unittest.TestCase):
local_month = cal.formatmonthname(2010, 10, 10)
self.assertIn('class="text-center month"', local_month)
+ def test_locale_html_calendar_custom_css_class_weekday(self):
+ try:
+ cal = calendar.LocaleHTMLCalendar(locale='')
+ local_weekday = cal.formatweekday(6)
+ except locale.Error:
+ # cannot set the system default locale -- skip rest of test
+ raise unittest.SkipTest('cannot set the system default locale')
+ self.assertIn('class="sun"', local_weekday)
+ cal.cssclasses_weekday_head = [ "mon2", "tue2", "wed2", "thu2",
+ "fri2", "sat2", "sun2"]
+ local_weekday = cal.formatweekday(6)
+ self.assertIn('class="sun2"', local_weekday)
+ Otherwise the patch looks good. |
@srinivasreddy, please the last code review request. Thank you! |
@csabella |
https://bugs.python.org/issue35078