]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #28255: calendar.TextCalendar.prweek() no longer prints a space after
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 25 Oct 2016 12:20:58 +0000 (15:20 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Tue, 25 Oct 2016 12:20:58 +0000 (15:20 +0300)
a weeks's calendar.  calendar.TextCalendar.pryear() no longer prints redundant
newline after a year's calendar.  Based on patch by Xiang Zhang.

Lib/calendar.py
Lib/test/test_calendar.py
Misc/NEWS

index 07594f3a833d7b8f4eb18a5596bf4fe55ae1775d..28ac56fdbe858dc9b53749d78a808bfd932e5b8c 100644 (file)
@@ -267,7 +267,7 @@ class TextCalendar(Calendar):
         """
         Print a single week (no newline).
         """
-        print(self.formatweek(theweek, width), end=' ')
+        print(self.formatweek(theweek, width), end='')
 
     def formatday(self, day, weekday, width):
         """
@@ -371,7 +371,7 @@ class TextCalendar(Calendar):
 
     def pryear(self, theyear, w=0, l=0, c=6, m=3):
         """Print a year's calendar."""
-        print(self.formatyear(theyear, w, l, c, m))
+        print(self.formatyear(theyear, w, l, c, m), end='')
 
 
 class HTMLCalendar(Calendar):
index 2bc4feebbd359eb63a59f3041bb4f61abf99058e..bd57653ffadc1606b29e49c62d96abe81656469d 100644 (file)
@@ -404,7 +404,7 @@ class OutputTestCase(unittest.TestCase):
         with support.captured_stdout() as out:
             week = [(1,0), (2,1), (3,2), (4,3), (5,4), (6,5), (7,6)]
             calendar.TextCalendar().prweek(week, 1)
-            self.assertEqual(out.getvalue().strip(), "1  2  3  4  5  6  7")
+            self.assertEqual(out.getvalue(), " 1  2  3  4  5  6  7")
 
     def test_prmonth(self):
         with support.captured_stdout() as out:
@@ -414,7 +414,7 @@ class OutputTestCase(unittest.TestCase):
     def test_pryear(self):
         with support.captured_stdout() as out:
             calendar.TextCalendar().pryear(2004)
-            self.assertEqual(out.getvalue().strip(), result_2004_text.strip())
+            self.assertEqual(out.getvalue(), result_2004_text)
 
     def test_format(self):
         with support.captured_stdout() as out:
index c335fe0e27d0678f0b4aa24e9b6929358c436a04..f6cf545f670532dd6c18f11f1901fec3768023a1 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -97,7 +97,11 @@ Core and Builtins
 Library
 -------
 
-- Issue #28255: calendar.TextCalendar().prmonth() no longer prints a space
+- Issue #28255: calendar.TextCalendar.prweek() no longer prints a space after
+  a weeks's calendar.  calendar.TextCalendar.pryear() no longer prints redundant
+  newline after a year's calendar.  Based on patch by Xiang Zhang.
+
+- Issue #28255: calendar.TextCalendar.prmonth() no longer prints a space
   at the start of new line after printing a month's calendar.  Patch by
   Xiang Zhang.