Skip to content

Commit 1f993dc

Browse files
committed
Add tests
1 parent 210337b commit 1f993dc

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

Lib/test/test_pyrepl/test_pyrepl.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import tempfile
1212
from pkgutil import ModuleInfo
1313
from unittest import TestCase, skipUnless, skipIf, SkipTest
14-
from unittest.mock import patch
14+
from unittest.mock import Mock, patch
1515
from test.support import force_not_colorized, make_clean_env, Py_DEBUG
1616
from test.support import has_subprocess_support, SHORT_TIMEOUT, STDLIB_DIR
1717
from test.support.import_helper import import_module
@@ -1908,3 +1908,43 @@ def test_ctrl_d_single_line_end_no_newline(self):
19081908
)
19091909
reader, _ = handle_all_events(events)
19101910
self.assertEqual("hello", "".join(reader.buffer))
1911+
1912+
1913+
@skipUnless(sys.platform == "win32", "windows console only")
1914+
class TestWindowsConsoleEolWrap(TestCase):
1915+
def _make_mock_console(self, width=80):
1916+
from _pyrepl import windows_console as wc
1917+
1918+
console = object.__new__(wc.WindowsConsole)
1919+
1920+
console.width = width
1921+
console.posxy = (0, 0)
1922+
console.screen = [""]
1923+
1924+
console._hide_cursor = Mock()
1925+
console._show_cursor = Mock()
1926+
console._erase_to_end = Mock()
1927+
console._move_relative = Mock()
1928+
console.move_cursor = Mock()
1929+
console._WindowsConsole__write = Mock()
1930+
1931+
return console, wc
1932+
1933+
def test_normal_line_not_full(self):
1934+
width = 10
1935+
console, wc = self._make_mock_console(width=width)
1936+
new_line = "a" * 3
1937+
wc.WindowsConsole._WindowsConsole__write_changed_line(
1938+
console, 0, "", new_line, 0
1939+
)
1940+
self.assertEqual(console.posxy, (3, 0))
1941+
1942+
def test_exact_width_line_wrap_behavior(self):
1943+
width = 10
1944+
console, wc = self._make_mock_console(width=width)
1945+
new_line = "a" * width
1946+
1947+
wc.WindowsConsole._WindowsConsole__write_changed_line(
1948+
console, 0, "", new_line, 0
1949+
)
1950+
self.assertEqual(console.posxy, (width - 1, 0))

0 commit comments

Comments
 (0)