From fcf589862fb6449c05478dd6df16767c9f5c34b9 2009-08-04 01:18:28 From: Fernando Perez Date: 2009-08-04 01:18:28 Subject: [PATCH] Fixes so the test suite runs when Twisted is not available. Other minor cleanups (formatting and unused imports) --- 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..0f313dc 100644 --- a/IPython/kernel/engineservice.py +++ b/IPython/kernel/engineservice.py @@ -23,6 +23,9 @@ method that automatically added methods to engines. __docformat__ = "restructuredtext en" +# Tell nose to skip this module +__test__ = {} + #------------------------------------------------------------------------------- # Copyright (C) 2008 The IPython Development Team # @@ -34,12 +37,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 +47,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 0f347d2..48ed1e7 100644 --- a/IPython/testing/iptest.py +++ b/IPython/testing/iptest.py @@ -107,6 +107,23 @@ if not os.name == 'posix': if not have_pexpect: EXCLUDE.append(pjoin('IPython', 'irunner')) +if not have_twisted: + 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', 'kernel', 'error')) + EXCLUDE.append(pjoin('IPython', 'testing', 'parametric')) + EXCLUDE.append(pjoin('IPython', 'testing', 'util')) + EXCLUDE.append(pjoin('IPython', 'testing', 'tests', 'test_decorators_trial')) + + # This is needed for the reg-exp to match on win32 in the ipdoctest plugin. if sys.platform == 'win32': EXCLUDE = [s.replace('\\','\\\\') for s in EXCLUDE] @@ -232,12 +249,15 @@ def make_runners(): 'Logger.py', 'macro.py', 'Magic.py', 'OInspect.py', 'OutputTrap.py', 'platutils.py', 'prefilter.py', 'Prompts.py', 'PyColorize.py', 'Release.py', 'rlineimpl.py', 'shadowns.py', - 'shellglobals.py', 'strdispatch.py', 'twshell.py', + 'shellglobals.py', 'strdispatch.py', 'ultraTB.py', 'upgrade_dir.py', 'usage.py', 'wildcard.py', # See note above for why this is skipped # 'Shell.py', 'winconsole.py'] + if have_twisted: + top_mod.append('twshell.py') + if have_pexpect: top_mod.append('irunner.py') diff --git a/IPython/tests/test_magic.py b/IPython/tests/test_magic.py index c602217..7d2f2f4 100644 --- a/IPython/tests/test_magic.py +++ b/IPython/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/twshell.py b/IPython/twshell.py index f00ab02..1b750ed 100644 --- a/IPython/twshell.py +++ b/IPython/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