Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e8d8a60

Browse files
committed
Tests: Allow setting a custom timeout scale
Add environment variable IPYTHON_TESTING_TIMEOUT_SCALE that can be used to scale all the timeouts in tests. Useful on slow machines, such as Fedora armv7hl/aarch64 builders. Fixes #11754
1 parent 78886a9 commit e8d8a60

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

IPython/terminal/tests/test_debug_magic.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import os
1515
import sys
1616
from IPython.testing.decorators import skip_win32
17+
from IPython.testing import IPYTHON_TESTING_TIMEOUT_SCALE
1718

1819
#-----------------------------------------------------------------------------
1920
# Tests
@@ -31,11 +32,11 @@ def test_debug_magic_passes_through_generators():
3132
env = os.environ.copy()
3233
child = pexpect.spawn(sys.executable, ['-m', 'IPython', '--colors=nocolor', '--simple-prompt'],
3334
env=env)
34-
child.timeout = 15
35+
child.timeout = 15 * IPYTHON_TESTING_TIMEOUT_SCALE
3536

3637
child.expect(in_prompt)
3738

38-
child.timeout = 2
39+
child.timeout = 2 * IPYTHON_TESTING_TIMEOUT_SCALE
3940

4041
child.sendline("def f(x):")
4142
child.sendline(" raise Exception")

IPython/terminal/tests/test_embed.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import nose.tools as nt
1818
from IPython.utils.tempdir import NamedFileInTemporaryDirectory
1919
from IPython.testing.decorators import skip_win32
20+
from IPython.testing import IPYTHON_TESTING_TIMEOUT_SCALE
2021

2122
#-----------------------------------------------------------------------------
2223
# Tests
@@ -72,7 +73,7 @@ def test_nest_embed():
7273

7374
child = pexpect.spawn(sys.executable, ['-m', 'IPython', '--colors=nocolor'],
7475
env=env)
75-
child.timeout = 5
76+
child.timeout = 5 * IPYTHON_TESTING_TIMEOUT_SCALE
7677
child.expect(ipy_prompt)
7778
child.sendline("import IPython")
7879
child.expect(ipy_prompt)

IPython/testing/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
# the file COPYING, distributed as part of this software.
99
#-----------------------------------------------------------------------------
1010

11+
12+
import os
13+
1114
#-----------------------------------------------------------------------------
1215
# Functions
1316
#-----------------------------------------------------------------------------
@@ -33,6 +36,14 @@ def test(**kwargs):
3336
setattr(options, name, val)
3437
run_iptestall(options)
3538

39+
#-----------------------------------------------------------------------------
40+
# Constants
41+
#-----------------------------------------------------------------------------
42+
43+
# We scale all timeouts via this factor, slow machines can increase it
44+
IPYTHON_TESTING_TIMEOUT_SCALE = float(os.getenv(
45+
'IPYTHON_TESTING_TIMEOUT_SCALE', 1))
46+
3647
# So nose doesn't try to run this as a test itself and we end up with an
3748
# infinite test loop
3849
test.__test__ = False

0 commit comments

Comments
 (0)