From b44b6920c0c90a7edfea943d60424f0322fba486 2009-08-04 16:50:23 From: Brian Granger Date: 2009-08-04 16:50:23 Subject: [PATCH] Merging -r 1196 from lp:ipython. A couple of issues came up: * Some tests in testing and frontend rely on twisted, but are being tested with nose. This is bad! We currently have hackish logic in iptest to skip these if twisted is not installed, but if it is we are testing them with nose! * Some modules (engineservice, kernel/error, newserialized) have nose skip logic even though they should never be tested with nose. * When trial is run on testStrictDict we get an uncaught error. testStrictDict ... ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multi-line statement', (37, 0)) --- diff --git a/IPython/core/tests/test_magic.py b/IPython/core/tests/test_magic.py index 75acc3b..7e1cd72 100644 --- a/IPython/core/tests/test_magic.py +++ b/IPython/core/tests/test_magic.py @@ -43,7 +43,6 @@ def doctest_hist_f(): In [10]: tfile = tempfile.mktemp('.py','tmp-ipython-') In [11]: %hist -n -f $tfile 3 - """ diff --git a/IPython/deathrow/twshell.py b/IPython/deathrow/twshell.py index 06fd047..6ad78fe 100644 --- a/IPython/deathrow/twshell.py +++ b/IPython/deathrow/twshell.py @@ -2,6 +2,9 @@ XXX - This module is missing proper docs. """ +# Tell nose to skip this module +__test__ = {} + import sys from twisted.internet import reactor, threads diff --git a/IPython/frontend/asyncfrontendbase.py b/IPython/frontend/asyncfrontendbase.py index cc7ada6..1171a83 100644 --- a/IPython/frontend/asyncfrontendbase.py +++ b/IPython/frontend/asyncfrontendbase.py @@ -3,6 +3,9 @@ Base front end class for all async frontends. """ __docformat__ = "restructuredtext en" +# Tell nose to skip this module +__test__ = {} + #------------------------------------------------------------------------------- # Copyright (C) 2008 The IPython Development Team # @@ -10,20 +13,25 @@ __docformat__ = "restructuredtext en" # the file COPYING, distributed as part of this software. #------------------------------------------------------------------------------- - #------------------------------------------------------------------------------- # Imports #------------------------------------------------------------------------------- +# Third-party +from twisted.python.failure import Failure +from zope.interface import implements, classProvides + +# From IPython from IPython.external import guid -from zope.interface import Interface, Attribute, implements, classProvides -from twisted.python.failure import Failure -from IPython.frontend.frontendbase import ( - FrontEndBase, IFrontEnd, IFrontEndFactory) +from IPython.frontend.frontendbase import (FrontEndBase, IFrontEnd, + IFrontEndFactory) from IPython.kernel.core.history import FrontEndHistory from IPython.kernel.engineservice import IEngineCore +#----------------------------------------------------------------------------- +# Classes and functions +#----------------------------------------------------------------------------- class AsyncFrontEndBase(FrontEndBase): """ @@ -41,8 +49,7 @@ class AsyncFrontEndBase(FrontEndBase): self.history = FrontEndHistory(input_cache=['']) else: self.history = history - - + def execute(self, block, blockID=None): """Execute the block and return the deferred result. @@ -73,5 +80,3 @@ class AsyncFrontEndBase(FrontEndBase): errback=self.render_error) return d - - diff --git a/IPython/frontend/tests/test_asyncfrontendbase.py b/IPython/frontend/tests/test_asyncfrontendbase.py index fb497c8..b52659b 100644 --- a/IPython/frontend/tests/test_asyncfrontendbase.py +++ b/IPython/frontend/tests/test_asyncfrontendbase.py @@ -3,6 +3,9 @@ """This file contains unittests for the asyncfrontendbase module.""" __docformat__ = "restructuredtext en" + +# Tell nose to skip this module +__test__ = {} #--------------------------------------------------------------------------- # Copyright (C) 2008 The IPython Development Team @@ -10,20 +13,21 @@ __docformat__ = "restructuredtext en" # Distributed under the terms of the BSD License. The full license is in # the file COPYING, distributed as part of this software. #--------------------------------------------------------------------------- - + #--------------------------------------------------------------------------- # Imports #--------------------------------------------------------------------------- -# Tell nose to skip this module -__test__ = {} - from twisted.trial import unittest + from IPython.frontend.asyncfrontendbase import AsyncFrontEndBase from IPython.frontend import frontendbase from IPython.kernel.engineservice import EngineService from IPython.testing.parametric import Parametric, parametric +#----------------------------------------------------------------------------- +# Classes and functions +#----------------------------------------------------------------------------- class FrontEndCallbackChecker(AsyncFrontEndBase): """FrontEndBase subclass for checking callbacks""" @@ -106,4 +110,3 @@ class TestAsyncFrontendBase(unittest.TestCase): def test_history_returns_none_at_startup(self): self.assert_(self.fb.get_history_previous("")==None) self.assert_(self.fb.get_history_next()==None) - diff --git a/IPython/kernel/engineservice.py b/IPython/kernel/engineservice.py index b400320..e5dadb3 100644 --- a/IPython/kernel/engineservice.py +++ b/IPython/kernel/engineservice.py @@ -23,6 +23,10 @@ method that automatically added methods to engines. __docformat__ = "restructuredtext en" +# Tell nose to skip this module. I don't think we need this as nose +# shouldn't ever be run on this! +__test__ = {} + #------------------------------------------------------------------------------- # Copyright (C) 2008 The IPython Development Team # @@ -34,12 +38,9 @@ __docformat__ = "restructuredtext en" # Imports #------------------------------------------------------------------------------- -# Tell nose to skip the testing of this module -__test__ = {} - -import os, sys, copy +import copy +import sys import cPickle as pickle -from new import instancemethod from twisted.application import service from twisted.internet import defer, reactor @@ -47,11 +48,7 @@ from twisted.python import log, failure, components import zope.interface as zi from IPython.kernel.core.interpreter import Interpreter -from IPython.kernel import newserialized, error, util -from IPython.kernel.util import printer -from IPython.kernel.twistedutil import gatherBoth, DeferredList -from IPython.kernel import codeutil - +from IPython.kernel import newserialized, error #------------------------------------------------------------------------------- # Interface specification for the Engine diff --git a/IPython/kernel/error.py b/IPython/kernel/error.py index d91f9e0..77db614 100644 --- a/IPython/kernel/error.py +++ b/IPython/kernel/error.py @@ -4,6 +4,9 @@ __docformat__ = "restructuredtext en" +# Tell nose to skip this module +__test__ = {} + #------------------------------------------------------------------------------- # Copyright (C) 2008 The IPython Development Team # @@ -14,9 +17,9 @@ __docformat__ = "restructuredtext en" #------------------------------------------------------------------------------- # Imports #------------------------------------------------------------------------------- +from twisted.python import failure from IPython.kernel.core import error -from twisted.python import failure #------------------------------------------------------------------------------- # Error classes diff --git a/IPython/kernel/newserialized.py b/IPython/kernel/newserialized.py index 38ba3c7..155ed0c 100644 --- a/IPython/kernel/newserialized.py +++ b/IPython/kernel/newserialized.py @@ -5,6 +5,9 @@ __docformat__ = "restructuredtext en" +# Tell nose to skip this module +__test__ = {} + #------------------------------------------------------------------------------- # Copyright (C) 2008 The IPython Development Team # @@ -18,8 +21,8 @@ __docformat__ = "restructuredtext en" import cPickle as pickle -from zope.interface import Interface, implements from twisted.python import components +from zope.interface import Interface, implements try: import numpy @@ -28,6 +31,10 @@ except ImportError: from IPython.kernel.error import SerializationError +#----------------------------------------------------------------------------- +# Classes and functions +#----------------------------------------------------------------------------- + class ISerialized(Interface): def getData(): diff --git a/IPython/testing/iptest.py b/IPython/testing/iptest.py index 387816d..4858d89 100644 --- a/IPython/testing/iptest.py +++ b/IPython/testing/iptest.py @@ -108,6 +108,27 @@ def make_exclude(): if not have_pexpect: EXCLUDE.append(pjoin('IPython', 'scripts', 'irunner')) + # This is scary. We still have things in frontend and testing that + # are being tested by nose that use twisted. We need to rethink + # how we are isolating dependencies in testing. + if not (have_twisted and have_zi and have_foolscap): + EXCLUDE.append(pjoin('IPython', 'frontend', 'asyncfrontendbase')) + EXCLUDE.append(pjoin('IPython', 'frontend', 'prefilterfrontend')) + EXCLUDE.append(pjoin('IPython', 'frontend', 'frontendbase')) + EXCLUDE.append(pjoin('IPython', 'frontend', 'linefrontendbase')) + EXCLUDE.append(pjoin('IPython', 'frontend', 'tests', + 'test_linefrontend')) + EXCLUDE.append(pjoin('IPython', 'frontend', 'tests', + 'test_frontendbase')) + EXCLUDE.append(pjoin('IPython', 'frontend', 'tests', + 'test_prefilterfrontend')) + EXCLUDE.append(pjoin('IPython', 'frontend', 'tests', + 'test_asyncfrontendbase')), + EXCLUDE.append(pjoin('IPython', 'testing', 'parametric')) + EXCLUDE.append(pjoin('IPython', 'testing', 'util')) + EXCLUDE.append(pjoin('IPython', 'testing', 'tests', + 'test_decorators_trial')) + # Skip shell always because of a bug in FakeModule. EXCLUDE.append(pjoin('IPython', 'core', 'shell'))