##// END OF EJS Templates
Fixing misc testing related things.
Brian Granger -
Show More
@@ -14,12 +14,13 b' __docformat__ = "restructuredtext en"'
14 14 #-------------------------------------------------------------------------------
15 15 # Imports
16 16 #-------------------------------------------------------------------------------
17 from IPython.external import guid
18 17
18 from IPython.external import guid
19 19
20 20 from zope.interface import Interface, Attribute, implements, classProvides
21 21 from twisted.python.failure import Failure
22 from IPython.frontend.frontendbase import FrontEndBase, IFrontEnd, IFrontEndFactory
22 from IPython.frontend.frontendbase import (
23 FrontEndBase, IFrontEnd, IFrontEndFactory)
23 24 from IPython.kernel.core.history import FrontEndHistory
24 25 from IPython.kernel.engineservice import IEngineCore
25 26
@@ -15,31 +15,38 b' __docformat__ = "restructuredtext en"'
15 15 # Imports
16 16 #---------------------------------------------------------------------------
17 17
18 # Tell nose to skip this module
19 __test__ = {}
20
21 from twisted.trial import unittest
22 from twisted.internet.defer import succeed
23
24 from IPython.kernel.core.interpreter import Interpreter
25 import IPython.kernel.engineservice as es
18 26
19 27 try:
20 from IPython.kernel.core.interpreter import Interpreter
21 import IPython.kernel.engineservice as es
22 from IPython.testing.util import DeferredTestCase
23 from twisted.internet.defer import succeed
24 from IPython.frontend.cocoa.cocoa_frontend import IPythonCocoaController
28 from IPython.frontend.cocoa.cocoa_frontend import IPythonCocoaController
25 29 from Foundation import NSMakeRect
26 30 from AppKit import NSTextView, NSScrollView
27 31 except ImportError:
28 import nose
29 raise nose.SkipTest("This test requires zope.interface, Twisted, Foolscap and PyObjC")
32 # This tells twisted.trial to skip this module if PyObjC is not found
33 skip = True
30 34
31 class TestIPythonCocoaControler(DeferredTestCase):
35 #---------------------------------------------------------------------------
36 # Tests
37 #---------------------------------------------------------------------------
38 class TestIPythonCocoaControler(unittest.TestCase):
32 39 """Tests for IPythonCocoaController"""
33
40
34 41 def setUp(self):
35 42 self.controller = IPythonCocoaController.alloc().init()
36 43 self.engine = es.EngineService()
37 44 self.engine.startService()
38
45
39 46 def tearDown(self):
40 47 self.controller = None
41 48 self.engine.stopService()
42
49
43 50 def testControllerExecutesCode(self):
44 51 code ="""5+5"""
45 52 expected = Interpreter().execute(code)
@@ -48,48 +55,46 b' class TestIPythonCocoaControler(DeferredTestCase):'
48 55 del result['number']
49 56 del result['id']
50 57 return result
51 self.assertDeferredEquals(
52 self.controller.execute(code).addCallback(removeNumberAndID),
53 expected)
54
58 d = self.controller.execute(code)
59 d.addCallback(removeNumberAndID)
60 d.addCallback(lambda r: self.assertEquals(r, expected))
61
55 62 def testControllerMirrorsUserNSWithValuesAsStrings(self):
56 63 code = """userns1=1;userns2=2"""
57 64 def testControllerUserNS(result):
58 65 self.assertEquals(self.controller.userNS['userns1'], 1)
59 66 self.assertEquals(self.controller.userNS['userns2'], 2)
60
61 67 self.controller.execute(code).addCallback(testControllerUserNS)
62
63
68
64 69 def testControllerInstantiatesIEngine(self):
65 70 self.assert_(es.IEngineBase.providedBy(self.controller.engine))
66
71
67 72 def testControllerCompletesToken(self):
68 73 code = """longNameVariable=10"""
69 74 def testCompletes(result):
70 75 self.assert_("longNameVariable" in result)
71
76
72 77 def testCompleteToken(result):
73 78 self.controller.complete("longNa").addCallback(testCompletes)
74
79
75 80 self.controller.execute(code).addCallback(testCompletes)
76
77
81
82
78 83 def testCurrentIndent(self):
79 84 """test that current_indent_string returns current indent or None.
80 85 Uses _indent_for_block for direct unit testing.
81 86 """
82
87
83 88 self.controller.tabUsesSpaces = True
84 89 self.assert_(self.controller._indent_for_block("""a=3""") == None)
85 90 self.assert_(self.controller._indent_for_block("") == None)
86 91 block = """def test():\n a=3"""
87 92 self.assert_(self.controller._indent_for_block(block) == \
88 93 ' ' * self.controller.tabSpaces)
89
94
90 95 block = """if(True):\n%sif(False):\n%spass""" % \
91 96 (' '*self.controller.tabSpaces,
92 97 2*' '*self.controller.tabSpaces)
93 98 self.assert_(self.controller._indent_for_block(block) == \
94 99 2*(' '*self.controller.tabSpaces))
95
100
@@ -15,16 +15,14 b' __docformat__ = "restructuredtext en"'
15 15 # Imports
16 16 #---------------------------------------------------------------------------
17 17
18 # Tell nose to skip this module
19 __test__ = {}
18 20
19 try:
20 from twisted.trial import unittest
21 from IPython.frontend.asyncfrontendbase import AsyncFrontEndBase
22 from IPython.frontend import frontendbase
23 from IPython.kernel.engineservice import EngineService
24 from IPython.testing.parametric import Parametric, parametric
25 except ImportError:
26 import nose
27 raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap")
21 from twisted.trial import unittest
22 from IPython.frontend.asyncfrontendbase import AsyncFrontEndBase
23 from IPython.frontend import frontendbase
24 from IPython.kernel.engineservice import EngineService
25 from IPython.testing.parametric import Parametric, parametric
28 26
29 27
30 28 class FrontEndCallbackChecker(AsyncFrontEndBase):
@@ -5,12 +5,12 b' Test process execution and IO redirection.'
5 5
6 6 __docformat__ = "restructuredtext en"
7 7
8 #-------------------------------------------------------------------------------
9 # Copyright (C) 2008 The IPython Development Team
8 #-----------------------------------------------------------------------------
9 # Copyright (C) 2008-2009 The IPython Development Team
10 10 #
11 11 # Distributed under the terms of the BSD License. The full license is
12 12 # in the file COPYING, distributed as part of this software.
13 #-------------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14 14
15 15 from cStringIO import StringIO
16 16 from time import sleep
@@ -22,6 +22,9 b' from IPython.kernel.core.interpreter import Interpreter'
22 22 # Tests
23 23 #-----------------------------------------------------------------------------
24 24
25 # Tell nose to skip this module
26 __test__ = {}
27
25 28 class TestInterpreter(unittest.TestCase):
26 29
27 30 def test_unicode(self):
@@ -15,6 +15,9 b' __docformat__ = "restructuredtext en"'
15 15 # Imports
16 16 #-----------------------------------------------------------------------------
17 17
18 # Tell nose to skip this module
19 __test__ = {}
20
18 21 import unittest
19 22 import IPython.kernel.core.notification as notification
20 23 from nose.tools import timed
@@ -12,12 +12,12 b' __docformat__ = "restructuredtext en"'
12 12 # in the file COPYING, distributed as part of this software.
13 13 #-------------------------------------------------------------------------------
14 14
15 # Tell nose to skip this module
16 __test__ = {}
15 17
16 # Stdlib imports
17 18 import os
18 19 from cStringIO import StringIO
19 20
20 # Our own imports
21 21 from IPython.testing import decorators as dec
22 22
23 23 #-----------------------------------------------------------------------------
@@ -1,3 +1,6 b''
1 # Tell nose to skip this module
2 __test__ = {}
3
1 4 #from __future__ import with_statement
2 5
3 6 # XXX This file is currently disabled to preserve 2.4 compatibility.
@@ -23,15 +23,15 b' __docformat__ = "restructuredtext en"'
23 23 # Imports
24 24 #-------------------------------------------------------------------------------
25 25
26 try:
27 from twisted.application.service import IService
28 from IPython.kernel.controllerservice import ControllerService
29 from IPython.kernel.tests import multienginetest as met
30 from controllertest import IControllerCoreTestCase
31 from IPython.testing.util import DeferredTestCase
32 except ImportError:
33 import nose
34 raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap")
26 # Tell nose to skip this module
27 __test__ = {}
28
29 from twisted.application.service import IService
30 from IPython.kernel.controllerservice import ControllerService
31 from IPython.kernel.tests import multienginetest as met
32 from controllertest import IControllerCoreTestCase
33 from IPython.testing.util import DeferredTestCase
34
35 35
36 36 class BasicControllerServiceTest(DeferredTestCase,
37 37 IControllerCoreTestCase):
@@ -15,30 +15,29 b' __docformat__ = "restructuredtext en"'
15 15 # Imports
16 16 #-------------------------------------------------------------------------------
17 17
18 try:
19 from twisted.python import components
20 from twisted.internet import reactor, defer
21 from twisted.spread import pb
22 from twisted.internet.base import DelayedCall
23 DelayedCall.debug = True
18 # Tell nose to skip this module
19 __test__ = {}
24 20
25 import zope.interface as zi
21 from twisted.python import components
22 from twisted.internet import reactor, defer
23 from twisted.spread import pb
24 from twisted.internet.base import DelayedCall
25 DelayedCall.debug = True
26 26
27 from IPython.kernel.fcutil import Tub, UnauthenticatedTub
28 from IPython.kernel import engineservice as es
29 from IPython.testing.util import DeferredTestCase
30 from IPython.kernel.controllerservice import IControllerBase
31 from IPython.kernel.enginefc import FCRemoteEngineRefFromService, IEngineBase
32 from IPython.kernel.engineservice import IEngineQueued
33 from IPython.kernel.engineconnector import EngineConnector
34
35 from IPython.kernel.tests.engineservicetest import \
36 IEngineCoreTestCase, \
37 IEngineSerializedTestCase, \
38 IEngineQueuedTestCase
39 except ImportError:
40 import nose
41 raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap")
27 import zope.interface as zi
28
29 from IPython.kernel.fcutil import Tub, UnauthenticatedTub
30 from IPython.kernel import engineservice as es
31 from IPython.testing.util import DeferredTestCase
32 from IPython.kernel.controllerservice import IControllerBase
33 from IPython.kernel.enginefc import FCRemoteEngineRefFromService, IEngineBase
34 from IPython.kernel.engineservice import IEngineQueued
35 from IPython.kernel.engineconnector import EngineConnector
36
37 from IPython.kernel.tests.engineservicetest import \
38 IEngineCoreTestCase, \
39 IEngineSerializedTestCase, \
40 IEngineQueuedTestCase
42 41
43 42
44 43 class EngineFCTest(DeferredTestCase,
@@ -23,20 +23,19 b' __docformat__ = "restructuredtext en"'
23 23 # Imports
24 24 #-------------------------------------------------------------------------------
25 25
26 try:
27 from twisted.internet import defer
28 from twisted.application.service import IService
29
30 from IPython.kernel import engineservice as es
31 from IPython.testing.util import DeferredTestCase
32 from IPython.kernel.tests.engineservicetest import \
33 IEngineCoreTestCase, \
34 IEngineSerializedTestCase, \
35 IEngineQueuedTestCase, \
36 IEnginePropertiesTestCase
37 except ImportError:
38 import nose
39 raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap")
26 # Tell nose to skip this module
27 __test__ = {}
28
29 from twisted.internet import defer
30 from twisted.application.service import IService
31
32 from IPython.kernel import engineservice as es
33 from IPython.testing.util import DeferredTestCase
34 from IPython.kernel.tests.engineservicetest import \
35 IEngineCoreTestCase, \
36 IEngineSerializedTestCase, \
37 IEngineQueuedTestCase, \
38 IEnginePropertiesTestCase
40 39
41 40
42 41 class BasicEngineServiceTest(DeferredTestCase,
@@ -15,18 +15,17 b' __docformat__ = "restructuredtext en"'
15 15 # Imports
16 16 #-----------------------------------------------------------------------------
17 17
18 try:
19 from twisted.internet import defer
20 from IPython.testing.util import DeferredTestCase
21 from IPython.kernel.controllerservice import ControllerService
22 from IPython.kernel import multiengine as me
23 from IPython.kernel.tests.multienginetest import (IMultiEngineTestCase,
24 ISynchronousMultiEngineTestCase)
25 except ImportError:
26 import nose
27 raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap")
28
29
18 # Tell nose to skip this module
19 __test__ = {}
20
21 from twisted.internet import defer
22 from IPython.testing.util import DeferredTestCase
23 from IPython.kernel.controllerservice import ControllerService
24 from IPython.kernel import multiengine as me
25 from IPython.kernel.tests.multienginetest import (IMultiEngineTestCase,
26 ISynchronousMultiEngineTestCase)
27
28
30 29 class BasicMultiEngineTestCase(DeferredTestCase, IMultiEngineTestCase):
31 30
32 31 def setUp(self):
@@ -14,25 +14,25 b' __docformat__ = "restructuredtext en"'
14 14 # Imports
15 15 #-------------------------------------------------------------------------------
16 16
17 try:
18 from twisted.internet import defer, reactor
17 # Tell nose to skip this module
18 __test__ = {}
19
20 from twisted.internet import defer, reactor
21
22 from IPython.kernel.fcutil import Tub, UnauthenticatedTub
23
24 from IPython.testing.util import DeferredTestCase
25 from IPython.kernel.controllerservice import ControllerService
26 from IPython.kernel.multiengine import IMultiEngine
27 from IPython.kernel.tests.multienginetest import IFullSynchronousMultiEngineTestCase
28 from IPython.kernel.multienginefc import IFCSynchronousMultiEngine
29 from IPython.kernel import multiengine as me
30 from IPython.kernel.clientconnector import ClientConnector
31 from IPython.kernel.parallelfunction import ParallelFunction
32 from IPython.kernel.error import CompositeError
33 from IPython.kernel.util import printer
19 34
20 from IPython.kernel.fcutil import Tub, UnauthenticatedTub
21 35
22 from IPython.testing.util import DeferredTestCase
23 from IPython.kernel.controllerservice import ControllerService
24 from IPython.kernel.multiengine import IMultiEngine
25 from IPython.kernel.tests.multienginetest import IFullSynchronousMultiEngineTestCase
26 from IPython.kernel.multienginefc import IFCSynchronousMultiEngine
27 from IPython.kernel import multiengine as me
28 from IPython.kernel.clientconnector import ClientConnector
29 from IPython.kernel.parallelfunction import ParallelFunction
30 from IPython.kernel.error import CompositeError
31 from IPython.kernel.util import printer
32 except ImportError:
33 import nose
34 raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap")
35
36 36 def _raise_it(f):
37 37 try:
38 38 f.raiseException()
@@ -15,21 +15,21 b' __docformat__ = "restructuredtext en"'
15 15 # Imports
16 16 #-----------------------------------------------------------------------------
17 17
18 try:
19 import zope.interface as zi
20 from twisted.trial import unittest
21 from IPython.testing.util import DeferredTestCase
18 # Tell nose to skip this module
19 __test__ = {}
20
21 import zope.interface as zi
22 from twisted.trial import unittest
23 from IPython.testing.util import DeferredTestCase
24
25 from IPython.kernel.newserialized import \
26 ISerialized, \
27 IUnSerialized, \
28 Serialized, \
29 UnSerialized, \
30 SerializeIt, \
31 UnSerializeIt
22 32
23 from IPython.kernel.newserialized import \
24 ISerialized, \
25 IUnSerialized, \
26 Serialized, \
27 UnSerialized, \
28 SerializeIt, \
29 UnSerializeIt
30 except ImportError:
31 import nose
32 raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap")
33 33
34 34 #-----------------------------------------------------------------------------
35 35 # Tests
@@ -16,18 +16,18 b' __docformat__ = "restructuredtext en"'
16 16 # Imports
17 17 #-------------------------------------------------------------------------------
18 18
19 try:
20 from twisted.internet import defer
21 from twisted.python import failure
22
23 from IPython.testing.util import DeferredTestCase
24 import IPython.kernel.pendingdeferred as pd
25 from IPython.kernel import error
26 from IPython.kernel.util import printer
27 except ImportError:
28 import nose
29 raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap")
30
19 # Tell nose to skip this module
20 __test__ = {}
21
22 from twisted.internet import defer
23 from twisted.python import failure
24
25 from IPython.testing.util import DeferredTestCase
26 import IPython.kernel.pendingdeferred as pd
27 from IPython.kernel import error
28 from IPython.kernel.util import printer
29
30
31 31 class Foo(object):
32 32
33 33 def bar(self, bahz):
@@ -15,19 +15,19 b' __docformat__ = "restructuredtext en"'
15 15 # Imports
16 16 #-------------------------------------------------------------------------------
17 17
18 try:
19 import time
20
21 from twisted.internet import defer
22 from twisted.trial import unittest
23
24 from IPython.kernel import task, controllerservice as cs, engineservice as es
25 from IPython.kernel.multiengine import IMultiEngine
26 from IPython.testing.util import DeferredTestCase
27 from IPython.kernel.tests.tasktest import ITaskControllerTestCase
28 except ImportError:
29 import nose
30 raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap")
18 # Tell nose to skip this module
19 __test__ = {}
20
21 import time
22
23 from twisted.internet import defer
24 from twisted.trial import unittest
25
26 from IPython.kernel import task, controllerservice as cs, engineservice as es
27 from IPython.kernel.multiengine import IMultiEngine
28 from IPython.testing.util import DeferredTestCase
29 from IPython.kernel.tests.tasktest import ITaskControllerTestCase
30
31 31
32 32 #-------------------------------------------------------------------------------
33 33 # Tests
@@ -14,27 +14,26 b' __docformat__ = "restructuredtext en"'
14 14 # Imports
15 15 #-------------------------------------------------------------------------------
16 16
17 try:
18 import time
17 # Tell nose to skip this module
18 __test__ = {}
19 19
20 from twisted.internet import defer, reactor
20 import time
21 21
22 from IPython.kernel.fcutil import Tub, UnauthenticatedTub
22 from twisted.internet import defer, reactor
23 23
24 from IPython.kernel import task as taskmodule
25 from IPython.kernel import controllerservice as cs
26 import IPython.kernel.multiengine as me
27 from IPython.testing.util import DeferredTestCase
28 from IPython.kernel.multienginefc import IFCSynchronousMultiEngine
29 from IPython.kernel.taskfc import IFCTaskController
30 from IPython.kernel.util import printer
31 from IPython.kernel.tests.tasktest import ITaskControllerTestCase
32 from IPython.kernel.clientconnector import ClientConnector
33 from IPython.kernel.error import CompositeError
34 from IPython.kernel.parallelfunction import ParallelFunction
35 except ImportError:
36 import nose
37 raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap")
24 from IPython.kernel.fcutil import Tub, UnauthenticatedTub
25
26 from IPython.kernel import task as taskmodule
27 from IPython.kernel import controllerservice as cs
28 import IPython.kernel.multiengine as me
29 from IPython.testing.util import DeferredTestCase
30 from IPython.kernel.multienginefc import IFCSynchronousMultiEngine
31 from IPython.kernel.taskfc import IFCTaskController
32 from IPython.kernel.util import printer
33 from IPython.kernel.tests.tasktest import ITaskControllerTestCase
34 from IPython.kernel.clientconnector import ClientConnector
35 from IPython.kernel.error import CompositeError
36 from IPython.kernel.parallelfunction import ParallelFunction
38 37
39 38
40 39 #-------------------------------------------------------------------------------
@@ -12,6 +12,9 b''
12 12 # Imports
13 13 #-----------------------------------------------------------------------------
14 14
15 # Tell nose to skip this module
16 __test__ = {}
17
15 18 import tempfile
16 19 import os, sys
17 20
@@ -123,10 +123,10 b' def skipif(skip_condition, msg=None):'
123 123 Parameters
124 124 ----------
125 125 skip_condition : bool or callable.
126 Flag to determine whether to skip test. If the condition is a
127 callable, it is used at runtime to dynamically make the decision. This
128 is useful for tests that may require costly imports, to delay the cost
129 until the test suite is actually executed.
126 Flag to determine whether to skip test. If the condition is a
127 callable, it is used at runtime to dynamically make the decision. This
128 is useful for tests that may require costly imports, to delay the cost
129 until the test suite is actually executed.
130 130 msg : string
131 131 Message to give on raising a SkipTest exception
132 132
General Comments 0
You need to be logged in to leave comments. Login now