From a97dcd318a60fb24234d5d6da54af52de33a6099 2010-01-13 07:21:21 From: Fernando Perez Date: 2010-01-13 07:21:21 Subject: [PATCH] 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. --- diff --git a/IPython/testing/decorators.py b/IPython/testing/decorators.py index 6f0e9b8..149dcdf 100644 --- a/IPython/testing/decorators.py +++ b/IPython/testing/decorators.py @@ -318,3 +318,7 @@ skip_if_not_osx = skipif(sys.platform != 'darwin', skipif_not_numpy = skipif(numpy_not_available,"This test requires numpy") skipknownfailure = skip('This test is known to fail') + +# A null 'decorator', useful to make more readable code that needs to pick +# between different decorators based on OS or other conditions +null_deco = lambda f: f diff --git a/IPython/testing/iptest.py b/IPython/testing/iptest.py index d32f802..3bcefa7 100644 --- a/IPython/testing/iptest.py +++ b/IPython/testing/iptest.py @@ -45,6 +45,7 @@ from nose.core import TestProgram from IPython.utils import genutils from IPython.utils.platutils import find_cmd, FindCmdError from . import globalipapp +from . import tools from .plugin.ipdoctest import IPythonDoctest pjoin = path.join @@ -57,6 +58,10 @@ pjoin = path.join warnings.filterwarnings('ignore', 'the sets module is deprecated', DeprecationWarning ) +# This one also comes from Twisted +warnings.filterwarnings('ignore', 'the sha module is deprecated', + DeprecationWarning) + #----------------------------------------------------------------------------- # Logic for skipping doctests #----------------------------------------------------------------------------- @@ -102,8 +107,11 @@ def make_exclude(): ipjoin('quarantine'), ipjoin('deathrow'), ipjoin('testing', 'attic'), - ipjoin('testing', 'tools'), + # This guy is probably attic material ipjoin('testing', 'mkdoctests'), + # Testing inputhook will need a lot of thought, to figure out + # how to have tests that don't lock up with the gui event + # loops in the picture ipjoin('lib', 'inputhook'), # Config files aren't really importable stand-alone ipjoin('config', 'default'), @@ -193,9 +201,9 @@ class IPTester(object): # path: iptest_path = pjoin(genutils.get_ipython_package_dir(), 'scripts','iptest') - self.runner = ['python', iptest_path, '-v'] + self.runner = tools.cmd2argv(iptest_path) + ['-v'] else: - self.runner = ['python', os.path.abspath(find_cmd('trial'))] + self.runner = tools.cmd2argv(os.path.abspath(find_cmd('trial'))) if params is None: params = [] if isinstance(params,str): diff --git a/IPython/testing/ipunittest.py b/IPython/testing/ipunittest.py index fe57e4e..d4a7609 100644 --- a/IPython/testing/ipunittest.py +++ b/IPython/testing/ipunittest.py @@ -52,8 +52,6 @@ if sys.version[0]=='2': else: from ._paramtestpy3 import ParametricTestCase -from . import globalipapp - #----------------------------------------------------------------------------- # Classes and functions #----------------------------------------------------------------------------- @@ -83,6 +81,8 @@ class IPython2PythonConverter(object): def __call__(self, ds): """Convert IPython prompts to python ones in a string.""" + from . import globalipapp + pyps1 = '>>> ' pyps2 = '... ' pyout = '' diff --git a/IPython/testing/tools.py b/IPython/testing/tools.py index d382fb9..7853b7f 100644 --- a/IPython/testing/tools.py +++ b/IPython/testing/tools.py @@ -25,6 +25,7 @@ Authors #----------------------------------------------------------------------------- # Required modules and packages #----------------------------------------------------------------------------- +from __future__ import absolute_import import os import re @@ -42,6 +43,8 @@ except ImportError: from IPython.utils import genutils, platutils +from . import decorators as dec + #----------------------------------------------------------------------------- # Globals #----------------------------------------------------------------------------- @@ -62,7 +65,11 @@ if has_nose: # Functions and classes #----------------------------------------------------------------------------- +# The docstring for full_path doctests differently on win32 (different path +# separator) so just skip the doctest there. The example remains informative. +doctest_deco = dec.skip_doctest if sys.platform == 'win32' else dec.null_deco +@doctest_deco def full_path(startPath,files): """Make full paths for all the listed files, based on startPath. @@ -142,6 +149,40 @@ def parse_test_output(txt): parse_test_output.__test__ = False +def cmd2argv(cmd): + r"""Take the path of a command and return a list (argv-style). + + For a given path ``cmd``, this returns [cmd] if cmd's extension is .exe, + .com or .bat, and ['python', cmd] otherwise. + + This is mostly a Windows utility, to deal with the fact that the scripts in + Windows get wrapped in .exe entry points, so we have to call them + differently. + + Parameters + ---------- + cmd : string + The path of the command. + + Returns + ------- + argv-style list. + + Examples + -------- + In [2]: cmd2argv('/usr/bin/ipython') + Out[2]: ['python', '/usr/bin/ipython'] + + In [3]: cmd2argv(r'C:\Python26\Scripts\ipython.exe') + Out[3]: ['C:\\Python26\\Scripts\\ipython.exe'] + """ + ext = os.path.splitext(cmd)[1] + if ext in ['.exe', '.com', '.bat']: + return [cmd] + else: + return ['python', cmd] + + def temp_pyfile(src, ext='.py'): """Make a temporary python file, return filename and filehandle.