mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
gh-124960: Fixed barry_as_FLUFL
future flag does not work in new REPL (#124999)
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
5f4e5b598c
commit
6a08a753b7
4 changed files with 40 additions and 5 deletions
|
@ -119,13 +119,38 @@ SyntaxError: duplicate argument 'x' in function definition"""
|
|||
|
||||
def test_no_active_future(self):
|
||||
console = InteractiveColoredConsole()
|
||||
source = "x: int = 1; print(__annotate__(1))"
|
||||
source = dedent("""\
|
||||
x: int = 1
|
||||
print(__annotate__(1))
|
||||
""")
|
||||
f = io.StringIO()
|
||||
with contextlib.redirect_stdout(f):
|
||||
result = console.runsource(source)
|
||||
self.assertFalse(result)
|
||||
self.assertEqual(f.getvalue(), "{'x': <class 'int'>}\n")
|
||||
|
||||
def test_future_annotations(self):
|
||||
console = InteractiveColoredConsole()
|
||||
source = dedent("""\
|
||||
from __future__ import annotations
|
||||
def g(x: int): ...
|
||||
print(g.__annotations__)
|
||||
""")
|
||||
f = io.StringIO()
|
||||
with contextlib.redirect_stdout(f):
|
||||
result = console.runsource(source)
|
||||
self.assertFalse(result)
|
||||
self.assertEqual(f.getvalue(), "{'x': 'int'}\n")
|
||||
|
||||
def test_future_barry_as_flufl(self):
|
||||
console = InteractiveColoredConsole()
|
||||
f = io.StringIO()
|
||||
with contextlib.redirect_stdout(f):
|
||||
result = console.runsource("from __future__ import barry_as_FLUFL\n")
|
||||
result = console.runsource("""print("black" <> 'blue')\n""")
|
||||
self.assertFalse(result)
|
||||
self.assertEqual(f.getvalue(), "True\n")
|
||||
|
||||
|
||||
class TestMoreLines(unittest.TestCase):
|
||||
def test_invalid_syntax_single_line(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue