Skip to content

Commit

Permalink
Fix some test on python 3.9 (nightly).
Browse files Browse the repository at this point in the history
Mostly

1) Pgen parser does not raise MemorryError anymore.
2) Function signature now understand "Optinal" correctly
  • Loading branch information
Carreau committed May 11, 2020
1 parent 98f6e03 commit 7432f3c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
13 changes: 8 additions & 5 deletions IPython/core/tests/test_async_helpers.py
Expand Up @@ -8,7 +8,7 @@
from textwrap import dedent, indent
from unittest import TestCase
from IPython.testing.decorators import skip_without

import sys

iprc = lambda x: ip.run_cell(dedent(x)).raise_error()
iprc_nr = lambda x: ip.run_cell(dedent(x))
Expand Down Expand Up @@ -275,10 +275,13 @@ def test_autoawait(self):
await sleep(0.1)
"""
)

def test_memory_error(self):
with self.assertRaises(MemoryError):
iprc("(" * 200 + ")" * 200)

if sys.version_info < (3,9):
# new pgen parser in 3.9 does not raise MemoryError on too many nested
# parens anymore
def test_memory_error(self):
with self.assertRaises(MemoryError):
iprc("(" * 200 + ")" * 200)

@skip_without('curio')
def test_autoawait_curio(self):
Expand Down
8 changes: 8 additions & 0 deletions IPython/core/tests/test_oinspect.py
Expand Up @@ -421,6 +421,14 @@ def long_function(
long_function.__name__,
)
nt.assert_in(sig, [
# Python >=3.9
'''\
long_function(
a_really_long_parameter: int,
and_another_long_one: bool = False,
let_us_make_sure_this_is_looong: Optional[str] = None,
) -> bool\
''',
# Python >=3.7
'''\
long_function(
Expand Down
16 changes: 10 additions & 6 deletions IPython/core/tests/test_ultratb.py
Expand Up @@ -247,12 +247,16 @@ def test_non_syntaxerror(self):
with tt.AssertPrints('QWERTY'):
ip.showsyntaxerror()


class MemoryErrorTest(unittest.TestCase):
def test_memoryerror(self):
memoryerror_code = "(" * 200 + ")" * 200
with tt.AssertPrints("MemoryError"):
ip.run_cell(memoryerror_code)
import sys
if sys.version_info < (3,9):
"""
New 3.9 Pgen Parser does not raise Memory error, except on failed malloc.
"""
class MemoryErrorTest(unittest.TestCase):
def test_memoryerror(self):
memoryerror_code = "(" * 200 + ")" * 200
with tt.AssertPrints("MemoryError"):
ip.run_cell(memoryerror_code)


class Python3ChainedExceptionsTest(unittest.TestCase):
Expand Down

0 comments on commit 7432f3c

Please sign in to comment.