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

Skip to content

Commit a97dcd3

Browse files
committed
Fixes for test suite in win32 when all dependencies (esp. Twisted) are
installed. Also activated testing.tools to be picked up by the test suite (was excluded), this gives us a few more tests. Status: - On Linux, the full suite passes like before. - On Win32, now that we have Twisted, we're seeing a few failures, because I don't have the WinHPC server stuff. These should be easy for Brian to fix. There are also two tests where the Skip nose exception isn't recognized by Twisted, should also be easy. I'll file tickets for those.
1 parent e8303d5 commit a97dcd3

4 files changed

Lines changed: 58 additions & 5 deletions

File tree

IPython/testing/decorators.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,7 @@ def numpy_not_available():
318318
skipif_not_numpy = skipif(numpy_not_available,"This test requires numpy")
319319

320320
skipknownfailure = skip('This test is known to fail')
321+
322+
# A null 'decorator', useful to make more readable code that needs to pick
323+
# between different decorators based on OS or other conditions
324+
null_deco = lambda f: f

IPython/testing/iptest.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
from IPython.utils import genutils
4646
from IPython.utils.platutils import find_cmd, FindCmdError
4747
from . import globalipapp
48+
from . import tools
4849
from .plugin.ipdoctest import IPythonDoctest
4950

5051
pjoin = path.join
@@ -57,6 +58,10 @@
5758
warnings.filterwarnings('ignore', 'the sets module is deprecated',
5859
DeprecationWarning )
5960

61+
# This one also comes from Twisted
62+
warnings.filterwarnings('ignore', 'the sha module is deprecated',
63+
DeprecationWarning)
64+
6065
#-----------------------------------------------------------------------------
6166
# Logic for skipping doctests
6267
#-----------------------------------------------------------------------------
@@ -102,8 +107,11 @@ def make_exclude():
102107
ipjoin('quarantine'),
103108
ipjoin('deathrow'),
104109
ipjoin('testing', 'attic'),
105-
ipjoin('testing', 'tools'),
110+
# This guy is probably attic material
106111
ipjoin('testing', 'mkdoctests'),
112+
# Testing inputhook will need a lot of thought, to figure out
113+
# how to have tests that don't lock up with the gui event
114+
# loops in the picture
107115
ipjoin('lib', 'inputhook'),
108116
# Config files aren't really importable stand-alone
109117
ipjoin('config', 'default'),
@@ -193,9 +201,9 @@ def __init__(self,runner='iptest',params=None):
193201
# path:
194202
iptest_path = pjoin(genutils.get_ipython_package_dir(),
195203
'scripts','iptest')
196-
self.runner = ['python', iptest_path, '-v']
204+
self.runner = tools.cmd2argv(iptest_path) + ['-v']
197205
else:
198-
self.runner = ['python', os.path.abspath(find_cmd('trial'))]
206+
self.runner = tools.cmd2argv(os.path.abspath(find_cmd('trial')))
199207
if params is None:
200208
params = []
201209
if isinstance(params,str):

IPython/testing/ipunittest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
else:
5353
from ._paramtestpy3 import ParametricTestCase
5454

55-
from . import globalipapp
56-
5755
#-----------------------------------------------------------------------------
5856
# Classes and functions
5957
#-----------------------------------------------------------------------------
@@ -83,6 +81,8 @@ def __init__(self):
8381

8482
def __call__(self, ds):
8583
"""Convert IPython prompts to python ones in a string."""
84+
from . import globalipapp
85+
8686
pyps1 = '>>> '
8787
pyps2 = '... '
8888
pyout = ''

IPython/testing/tools.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#-----------------------------------------------------------------------------
2626
# Required modules and packages
2727
#-----------------------------------------------------------------------------
28+
from __future__ import absolute_import
2829

2930
import os
3031
import re
@@ -42,6 +43,8 @@
4243

4344
from IPython.utils import genutils, platutils
4445

46+
from . import decorators as dec
47+
4548
#-----------------------------------------------------------------------------
4649
# Globals
4750
#-----------------------------------------------------------------------------
@@ -62,7 +65,11 @@ def %(name)s(*a,**kw):
6265
# Functions and classes
6366
#-----------------------------------------------------------------------------
6467

68+
# The docstring for full_path doctests differently on win32 (different path
69+
# separator) so just skip the doctest there. The example remains informative.
70+
doctest_deco = dec.skip_doctest if sys.platform == 'win32' else dec.null_deco
6571

72+
@doctest_deco
6673
def full_path(startPath,files):
6774
"""Make full paths for all the listed files, based on startPath.
6875
@@ -142,6 +149,40 @@ def parse_test_output(txt):
142149
parse_test_output.__test__ = False
143150

144151

152+
def cmd2argv(cmd):
153+
r"""Take the path of a command and return a list (argv-style).
154+
155+
For a given path ``cmd``, this returns [cmd] if cmd's extension is .exe,
156+
.com or .bat, and ['python', cmd] otherwise.
157+
158+
This is mostly a Windows utility, to deal with the fact that the scripts in
159+
Windows get wrapped in .exe entry points, so we have to call them
160+
differently.
161+
162+
Parameters
163+
----------
164+
cmd : string
165+
The path of the command.
166+
167+
Returns
168+
-------
169+
argv-style list.
170+
171+
Examples
172+
--------
173+
In [2]: cmd2argv('/usr/bin/ipython')
174+
Out[2]: ['python', '/usr/bin/ipython']
175+
176+
In [3]: cmd2argv(r'C:\Python26\Scripts\ipython.exe')
177+
Out[3]: ['C:\\Python26\\Scripts\\ipython.exe']
178+
"""
179+
ext = os.path.splitext(cmd)[1]
180+
if ext in ['.exe', '.com', '.bat']:
181+
return [cmd]
182+
else:
183+
return ['python', cmd]
184+
185+
145186
def temp_pyfile(src, ext='.py'):
146187
"""Make a temporary python file, return filename and filehandle.
147188

0 commit comments

Comments
 (0)