Skip to content

Commit 6597972

Browse files
committed
Finish: pass test!
1 parent 9f6dd09 commit 6597972

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Lib/calendar.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,8 @@ def main(args=None):
885885
cal = HTMLCalendar()
886886
cal.setfirstweekday(options.first_weekday)
887887
encoding = options.encoding
888+
if encoding is None:
889+
encoding = sys.getdefaultencoding()
888890
optdict = dict(encoding=encoding, css=options.css)
889891
write = sys.stdout.buffer.write
890892
if options.year is None:

Lib/test/test_calendar.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ def test_several_leapyears_in_range(self):
929929

930930

931931
def conv(s):
932-
return s.replace('\n', os.linesep).encode()
932+
return s.encode()
933933

934934
class CommandLineTestCase(unittest.TestCase):
935935
def setUp(self):
@@ -1035,7 +1035,6 @@ def test_option_encoding(self):
10351035
def test_option_locale(self):
10361036
self.assertFailure('-L')
10371037
self.assertFailure('--locale')
1038-
self.assertFailure('-L', 'en')
10391038

10401039
lang, enc = locale.getlocale()
10411040
lang = lang or 'C'
@@ -1069,7 +1068,7 @@ def test_option_lines(self):
10691068
self.assertFailure('-l', 'spam')
10701069
for run in self.runners:
10711070
output = run('--lines', '2', '2004')
1072-
self.assertIn(conv('December\n\nMo Tu We'), output)
1071+
self.assertRegex(output, br'December(\r\n|\n){2}Mo Tu We')
10731072

10741073
def test_option_spacing(self):
10751074
self.assertFailure('-s')
@@ -1085,7 +1084,7 @@ def test_option_months(self):
10851084
self.assertFailure('-m', 'spam')
10861085
for run in self.runners:
10871086
output = run('--months', '1', '2004')
1088-
self.assertIn(conv('\nMo Tu We Th Fr Sa Su\n'), output)
1087+
self.assertRegex(output, br'(\r\n|\n)Mo Tu We Th Fr Sa Su(\r\n|\n)')
10891088

10901089
def test_option_type(self):
10911090
self.assertFailure('-t')

0 commit comments

Comments
 (0)