##// END OF EJS Templates
Tweak tests for PyPy and add CI runner...
Nikita Kniazev -
Show More
@@ -33,6 +33,16 b' jobs:'
33 - os: ubuntu-latest
33 - os: ubuntu-latest
34 python-version: "3.11-dev"
34 python-version: "3.11-dev"
35 deps: test
35 deps: test
36 # Installing optional dependencies stuff takes ages on PyPy
37 - os: ubuntu-latest
38 python-version: "pypy-3.8"
39 deps: test
40 - os: windows-latest
41 python-version: "pypy-3.8"
42 deps: test
43 - os: macos-latest
44 python-version: "pypy-3.8"
45 deps: test
36
46
37 steps:
47 steps:
38 - uses: actions/checkout@v2
48 - uses: actions/checkout@v2
@@ -3,6 +3,7 b' Test for async helpers.'
3
3
4 Should only trigger on python 3.5+ or will have syntax errors.
4 Should only trigger on python 3.5+ or will have syntax errors.
5 """
5 """
6 import platform
6 from itertools import chain, repeat
7 from itertools import chain, repeat
7 from textwrap import dedent, indent
8 from textwrap import dedent, indent
8 from unittest import TestCase
9 from unittest import TestCase
@@ -275,7 +276,7 b' class AsyncTest(TestCase):'
275 """
276 """
276 )
277 )
277
278
278 if sys.version_info < (3,9):
279 if sys.version_info < (3, 9) and platform.python_implementation() != "PyPy":
279 # new pgen parser in 3.9 does not raise MemoryError on too many nested
280 # new pgen parser in 3.9 does not raise MemoryError on too many nested
280 # parens anymore
281 # parens anymore
281 def test_memory_error(self):
282 def test_memory_error(self):
@@ -371,11 +371,13 b' def _decorator_skip_setup():'
371 child = pexpect.spawn(
371 child = pexpect.spawn(
372 sys.executable, ["-m", "IPython", "--colors=nocolor"], env=env
372 sys.executable, ["-m", "IPython", "--colors=nocolor"], env=env
373 )
373 )
374 child.timeout = 5 * IPYTHON_TESTING_TIMEOUT_SCALE
374 child.timeout = 15 * IPYTHON_TESTING_TIMEOUT_SCALE
375
375
376 child.expect("IPython")
376 child.expect("IPython")
377 child.expect("\n")
377 child.expect("\n")
378
378
379 child.timeout = 5 * IPYTHON_TESTING_TIMEOUT_SCALE
380
379 dedented_blocks = [dedent(b).strip() for b in skip_decorators_blocks]
381 dedented_blocks = [dedent(b).strip() for b in skip_decorators_blocks]
380 in_prompt_number = 1
382 in_prompt_number = 1
381 for cblock in dedented_blocks:
383 for cblock in dedented_blocks:
@@ -448,11 +450,13 b' def test_decorator_skip_with_breakpoint():'
448 child = pexpect.spawn(
450 child = pexpect.spawn(
449 sys.executable, ["-m", "IPython", "--colors=nocolor"], env=env
451 sys.executable, ["-m", "IPython", "--colors=nocolor"], env=env
450 )
452 )
451 child.timeout = 5 * IPYTHON_TESTING_TIMEOUT_SCALE
453 child.timeout = 15 * IPYTHON_TESTING_TIMEOUT_SCALE
452
454
453 child.expect("IPython")
455 child.expect("IPython")
454 child.expect("\n")
456 child.expect("\n")
455
457
458 child.timeout = 5 * IPYTHON_TESTING_TIMEOUT_SCALE
459
456 ### we need a filename, so we need to exec the full block with a filename
460 ### we need a filename, so we need to exec the full block with a filename
457 with NamedTemporaryFile(suffix=".py", dir=".", delete=True) as tf:
461 with NamedTemporaryFile(suffix=".py", dir=".", delete=True) as tf:
458
462
@@ -2,6 +2,7 b''
2 """Tests for various magic functions."""
2 """Tests for various magic functions."""
3
3
4 import asyncio
4 import asyncio
5 import gc
5 import io
6 import io
6 import os
7 import os
7 import re
8 import re
@@ -576,6 +577,7 b' class TestXdel(tt.TempFileMixin):'
576 _ip.magic("xdel a")
577 _ip.magic("xdel a")
577
578
578 # Check that a's __del__ method has been called.
579 # Check that a's __del__ method has been called.
580 gc.collect(0)
579 assert monitor == [1]
581 assert monitor == [1]
580
582
581 def doctest_who():
583 def doctest_who():
@@ -18,6 +18,7 b' as otherwise it may influence later tests.'
18
18
19 import functools
19 import functools
20 import os
20 import os
21 import platform
21 from os.path import join as pjoin
22 from os.path import join as pjoin
22 import random
23 import random
23 import string
24 import string
@@ -158,7 +159,7 b' def doctest_reset_del():'
158
159
159 In [3]: a = A()
160 In [3]: a = A()
160
161
161 In [4]: get_ipython().reset()
162 In [4]: get_ipython().reset(); import gc; x = gc.collect(0)
162 Hi
163 Hi
163
164
164 In [5]: 1+1
165 In [5]: 1+1
@@ -241,6 +242,10 b' class TestMagicRunSimple(tt.TempFileMixin):'
241 _ip.run_cell("t = isinstance(f(), foo)")
242 _ip.run_cell("t = isinstance(f(), foo)")
242 assert _ip.user_ns["t"] is True
243 assert _ip.user_ns["t"] is True
243
244
245 @pytest.mark.xfail(
246 platform.python_implementation() == "PyPy",
247 reason="expecting __del__ call on exit is unreliable and doesn't happen on PyPy",
248 )
244 def test_obj_del(self):
249 def test_obj_del(self):
245 """Test that object's __del__ methods are called on exit."""
250 """Test that object's __del__ methods are called on exit."""
246 src = ("class A(object):\n"
251 src = ("class A(object):\n"
@@ -286,14 +291,20 b' class TestMagicRunSimple(tt.TempFileMixin):'
286 _ip.magic("run %s" % empty.fname)
291 _ip.magic("run %s" % empty.fname)
287 assert _ip.user_ns["afunc"]() == 1
292 assert _ip.user_ns["afunc"]() == 1
288
293
289 @dec.skip_win32
290 def test_tclass(self):
294 def test_tclass(self):
291 mydir = os.path.dirname(__file__)
295 mydir = os.path.dirname(__file__)
292 tc = os.path.join(mydir, 'tclass')
296 tc = os.path.join(mydir, "tclass")
293 src = ("%%run '%s' C-first\n"
297 src = f"""\
294 "%%run '%s' C-second\n"
298 import gc
295 "%%run '%s' C-third\n") % (tc, tc, tc)
299 %run "{tc}" C-first
296 self.mktmp(src, '.ipy')
300 gc.collect(0)
301 %run "{tc}" C-second
302 gc.collect(0)
303 %run "{tc}" C-third
304 gc.collect(0)
305 %reset -f
306 """
307 self.mktmp(src, ".ipy")
297 out = """\
308 out = """\
298 ARGV 1-: ['C-first']
309 ARGV 1-: ['C-first']
299 ARGV 1-: ['C-second']
310 ARGV 1-: ['C-second']
@@ -3,6 +3,7 b''
3 """
3 """
4 import io
4 import io
5 import logging
5 import logging
6 import platform
6 import re
7 import re
7 import sys
8 import sys
8 import os.path
9 import os.path
@@ -248,7 +249,8 b' bar()'
248 ip.showsyntaxerror()
249 ip.showsyntaxerror()
249
250
250 import sys
251 import sys
251 if sys.version_info < (3,9):
252
253 if sys.version_info < (3, 9) and platform.python_implementation() != "PyPy":
252 """
254 """
253 New 3.9 Pgen Parser does not raise Memory error, except on failed malloc.
255 New 3.9 Pgen Parser does not raise Memory error, except on failed malloc.
254 """
256 """
@@ -359,7 +361,7 b' def r3o2():'
359 ):
361 ):
360 ip.run_cell("r1()")
362 ip.run_cell("r1()")
361
363
362 @recursionlimit(200)
364 @recursionlimit(160)
363 def test_recursion_three_frames(self):
365 def test_recursion_three_frames(self):
364 with tt.AssertPrints("[... skipping similar frames: "), \
366 with tt.AssertPrints("[... skipping similar frames: "), \
365 tt.AssertPrints(re.compile(r"r3a at line 8 \(\d{2} times\)"), suppress=False), \
367 tt.AssertPrints(re.compile(r"r3a at line 8 \(\d{2} times\)"), suppress=False), \
@@ -13,6 +13,8 b''
13 # -----------------------------------------------------------------------------
13 # -----------------------------------------------------------------------------
14
14
15 import os
15 import os
16 import platform
17 import pytest
16 import sys
18 import sys
17 import tempfile
19 import tempfile
18 import textwrap
20 import textwrap
@@ -28,6 +30,12 b' from unittest import TestCase'
28 from IPython.extensions.autoreload import AutoreloadMagics
30 from IPython.extensions.autoreload import AutoreloadMagics
29 from IPython.core.events import EventManager, pre_run_cell
31 from IPython.core.events import EventManager, pre_run_cell
30
32
33 if platform.python_implementation() == "PyPy":
34 pytest.skip(
35 "Current autoreload implementation is extremly slow on PyPy",
36 allow_module_level=True,
37 )
38
31 # -----------------------------------------------------------------------------
39 # -----------------------------------------------------------------------------
32 # Test fixture
40 # Test fixture
33 # -----------------------------------------------------------------------------
41 # -----------------------------------------------------------------------------
@@ -51,6 +51,8 b' def test_debug_magic_passes_through_generators():'
51 child.sendline(" pass")
51 child.sendline(" pass")
52 child.sendline("")
52 child.sendline("")
53
53
54 child.timeout = 10 * IPYTHON_TESTING_TIMEOUT_SCALE
55
54 child.expect('Exception:')
56 child.expect('Exception:')
55
57
56 child.expect(in_prompt)
58 child.expect(in_prompt)
@@ -74,8 +74,9 b' def test_nest_embed():'
74
74
75 child = pexpect.spawn(sys.executable, ['-m', 'IPython', '--colors=nocolor'],
75 child = pexpect.spawn(sys.executable, ['-m', 'IPython', '--colors=nocolor'],
76 env=env)
76 env=env)
77 child.timeout = 5 * IPYTHON_TESTING_TIMEOUT_SCALE
77 child.timeout = 15 * IPYTHON_TESTING_TIMEOUT_SCALE
78 child.expect(ipy_prompt)
78 child.expect(ipy_prompt)
79 child.timeout = 5 * IPYTHON_TESTING_TIMEOUT_SCALE
79 child.sendline("import IPython")
80 child.sendline("import IPython")
80 child.expect(ipy_prompt)
81 child.expect(ipy_prompt)
81 child.sendline("ip0 = get_ipython()")
82 child.sendline("ip0 = get_ipython()")
@@ -37,10 +37,3 b' def doctest_ivars():'
37 In [6]: zz
37 In [6]: zz
38 Out[6]: 1
38 Out[6]: 1
39 """
39 """
40
41 def doctest_refs():
42 """DocTest reference holding issues when running scripts.
43
44 In [32]: run show_refs.py
45 c referrers: [<... 'dict'>]
46 """
@@ -131,7 +131,7 b' class Struct(dict):'
131 >>> s.a
131 >>> s.a
132 10
132 10
133 >>> type(s.get)
133 >>> type(s.get)
134 <... 'builtin_function_or_method'>
134 <...method'>
135 >>> try:
135 >>> try:
136 ... s.b
136 ... s.b
137 ... except AttributeError:
137 ... except AttributeError:
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now