diff options
author | Ćukasz Langa <lukasz@langa.pl> | 2025-05-02 18:22:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-02 18:22:31 (GMT) |
commit | fac41f56d4b6b858cb52b40529855cce85cdbdcc (patch) | |
tree | 70490d6d77240385c4ca99281c7e5333261e89dd /Lib/test/test_pyrepl/test_utils.py | |
parent | bfcbb28223b733b9cb88f152a059a9e1416f3467 (diff) | |
download | cpython-fac41f56d4b6b858cb52b40529855cce85cdbdcc.zip cpython-fac41f56d4b6b858cb52b40529855cce85cdbdcc.tar.gz cpython-fac41f56d4b6b858cb52b40529855cce85cdbdcc.tar.bz2 |
gh-131507: Add support for syntax highlighting in PyREPL (GH-133247)
Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_pyrepl/test_utils.py')
-rw-r--r-- | Lib/test/test_pyrepl/test_utils.py | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/Lib/test/test_pyrepl/test_utils.py b/Lib/test/test_pyrepl/test_utils.py index 0d59968..8ce1e53 100644 --- a/Lib/test/test_pyrepl/test_utils.py +++ b/Lib/test/test_pyrepl/test_utils.py @@ -1,6 +1,6 @@ from unittest import TestCase -from _pyrepl.utils import str_width, wlen +from _pyrepl.utils import str_width, wlen, prev_next_window class TestUtils(TestCase): @@ -25,3 +25,38 @@ class TestUtils(TestCase): self.assertEqual(wlen('hello'), 5) self.assertEqual(wlen('hello' + '\x1a'), 7) + + def test_prev_next_window(self): + def gen_normal(): + yield 1 + yield 2 + yield 3 + yield 4 + + pnw = prev_next_window(gen_normal()) + self.assertEqual(next(pnw), (None, 1, 2)) + self.assertEqual(next(pnw), (1, 2, 3)) + self.assertEqual(next(pnw), (2, 3, 4)) + self.assertEqual(next(pnw), (3, 4, None)) + with self.assertRaises(StopIteration): + next(pnw) + + def gen_short(): + yield 1 + + pnw = prev_next_window(gen_short()) + self.assertEqual(next(pnw), (None, 1, None)) + with self.assertRaises(StopIteration): + next(pnw) + + def gen_raise(): + yield from gen_normal() + 1/0 + + pnw = prev_next_window(gen_raise()) + self.assertEqual(next(pnw), (None, 1, 2)) + self.assertEqual(next(pnw), (1, 2, 3)) + self.assertEqual(next(pnw), (2, 3, 4)) + self.assertEqual(next(pnw), (3, 4, None)) + with self.assertRaises(ZeroDivisionError): + next(pnw) |