diff --git a/py/io/terminalwriter.py b/py/io/terminalwriter.py index f21dc5e4a..0dd04ae3c 100644 --- a/py/io/terminalwriter.py +++ b/py/io/terminalwriter.py @@ -63,7 +63,9 @@ if sys.platform == 'win32': info = CONSOLE_SCREEN_BUFFER_INFO() ctypes.windll.kernel32.GetConsoleScreenBufferInfo( handle, ctypes.byref(info)) - return info.dwSize.Y, info.dwSize.X + # Substract one from the width, otherwise the cursor wraps + # and the ending \n causes an empty line to display. + return info.dwSize.Y, info.dwSize.X - 1 def get_terminal_width(): try: @@ -218,9 +220,6 @@ class Win32ConsoleWriter(object): def sep(self, sepchar, title=None, fullwidth=None, **kw): if fullwidth is None: fullwidth = self.fullwidth - # On a Windows console, writing in the last column - # causes a line feed. - fullwidth -= 1 # the goal is to have the line be as long as possible # under the condition that len(line) <= fullwidth if title is not None: diff --git a/py/io/testing/test_terminalwriter.py b/py/io/testing/test_terminalwriter.py index 3fcffbc2d..10f3d9f4b 100644 --- a/py/io/testing/test_terminalwriter.py +++ b/py/io/testing/test_terminalwriter.py @@ -40,7 +40,6 @@ class BaseTests: tw.sep("-", fullwidth=60) l = self.getlines() assert len(l) == 1 - skip_win32() assert l[0] == "-" * 60 + "\n" def test_sep_with_title(self): @@ -48,7 +47,6 @@ class BaseTests: tw.sep("-", "hello", fullwidth=60) l = self.getlines() assert len(l) == 1 - skip_win32() assert l[0] == "-" * 26 + " hello " + "-" * 27 + "\n" def test__escaped(self):