gh-119443: Turn off from __future__ import annotations in REPL (#119493)

This commit is contained in:
Jelle Zijlstra 2024-05-28 17:05:18 -07:00 committed by GitHub
parent 548a11d5cf
commit a8e35e8eba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 1 deletions

View file

@ -94,3 +94,12 @@ class TestSimpleInteract(unittest.TestCase):
with patch.object(console, "showsyntaxerror") as mock_showsyntaxerror:
console.runsource(source)
mock_showsyntaxerror.assert_called_once()
def test_no_active_future(self):
console = InteractiveColoredConsole()
source = "x: int = 1; print(__annotations__)"
f = io.StringIO()
with contextlib.redirect_stdout(f):
result = console.runsource(source)
self.assertFalse(result)
self.assertEqual(f.getvalue(), "{'x': <class 'int'>}\n")