Show More
1 | NO CONTENT: modified file chmod 100755 => 100644 |
|
NO CONTENT: modified file chmod 100755 => 100644 |
1 | NO CONTENT: modified file chmod 100755 => 100644 |
|
NO CONTENT: modified file chmod 100755 => 100644 |
1 | NO CONTENT: modified file chmod 100755 => 100644 |
|
NO CONTENT: modified file chmod 100755 => 100644 |
1 | NO CONTENT: modified file chmod 100755 => 100644 |
|
NO CONTENT: modified file chmod 100755 => 100644 |
1 | NO CONTENT: modified file chmod 100755 => 100644 |
|
NO CONTENT: modified file chmod 100755 => 100644 |
@@ -26,10 +26,10 b' zope.interface is required to run asynchronous frontends.""" % e.message' | |||||
26 |
|
26 | |||
27 | from frontendbase import FrontEndBase, IFrontEnd, IFrontEndFactory |
|
27 | from frontendbase import FrontEndBase, IFrontEnd, IFrontEndFactory | |
28 |
|
28 | |||
29 | from IPython.kernel.engineservice import IEngineCore |
|
|||
30 | from IPython.kernel.core.history import FrontEndHistory |
|
29 | from IPython.kernel.core.history import FrontEndHistory | |
31 |
|
30 | |||
32 | try: |
|
31 | try: | |
|
32 | from IPython.kernel.engineservice import IEngineCore | |||
33 | from twisted.python.failure import Failure |
|
33 | from twisted.python.failure import Failure | |
34 | except ImportError, e: |
|
34 | except ImportError, e: | |
35 | e.message = """%s |
|
35 | e.message = """%s |
@@ -14,28 +14,31 b' __docformat__ = "restructuredtext en"' | |||||
14 | #--------------------------------------------------------------------------- |
|
14 | #--------------------------------------------------------------------------- | |
15 | # Imports |
|
15 | # Imports | |
16 | #--------------------------------------------------------------------------- |
|
16 | #--------------------------------------------------------------------------- | |
17 | from IPython.kernel.core.interpreter import Interpreter |
|
17 | ||
18 | import IPython.kernel.engineservice as es |
|
18 | try: | |
19 | from IPython.testing.util import DeferredTestCase |
|
19 | from IPython.kernel.core.interpreter import Interpreter | |
20 | from twisted.internet.defer import succeed |
|
20 | import IPython.kernel.engineservice as es | |
21 | from IPython.frontend.cocoa.cocoa_frontend import IPythonCocoaController |
|
21 | from IPython.testing.util import DeferredTestCase | |
22 |
|
22 | from twisted.internet.defer import succeed | ||
23 | from Foundation import NSMakeRect |
|
23 | from IPython.frontend.cocoa.cocoa_frontend import IPythonCocoaController | |
24 | from AppKit import NSTextView, NSScrollView |
|
24 | from Foundation import NSMakeRect | |
|
25 | from AppKit import NSTextView, NSScrollView | |||
|
26 | except ImportError: | |||
|
27 | import nose | |||
|
28 | raise nose.SkipTest("This test requires zope.interface, Twisted, Foolscap and PyObjC") | |||
25 |
|
29 | |||
26 | class TestIPythonCocoaControler(DeferredTestCase): |
|
30 | class TestIPythonCocoaControler(DeferredTestCase): | |
27 | """Tests for IPythonCocoaController""" |
|
31 | """Tests for IPythonCocoaController""" | |
28 |
|
|
32 | ||
29 | def setUp(self): |
|
33 | def setUp(self): | |
30 | self.controller = IPythonCocoaController.alloc().init() |
|
34 | self.controller = IPythonCocoaController.alloc().init() | |
31 | self.engine = es.EngineService() |
|
35 | self.engine = es.EngineService() | |
32 | self.engine.startService() |
|
36 | self.engine.startService() | |
33 |
|
|
37 | ||
34 |
|
||||
35 | def tearDown(self): |
|
38 | def tearDown(self): | |
36 | self.controller = None |
|
39 | self.controller = None | |
37 | self.engine.stopService() |
|
40 | self.engine.stopService() | |
38 |
|
|
41 | ||
39 | def testControllerExecutesCode(self): |
|
42 | def testControllerExecutesCode(self): | |
40 | code ="""5+5""" |
|
43 | code ="""5+5""" | |
41 | expected = Interpreter().execute(code) |
|
44 | expected = Interpreter().execute(code) | |
@@ -47,45 +50,45 b' class TestIPythonCocoaControler(DeferredTestCase):' | |||||
47 | self.assertDeferredEquals( |
|
50 | self.assertDeferredEquals( | |
48 | self.controller.execute(code).addCallback(removeNumberAndID), |
|
51 | self.controller.execute(code).addCallback(removeNumberAndID), | |
49 | expected) |
|
52 | expected) | |
50 |
|
|
53 | ||
51 | def testControllerMirrorsUserNSWithValuesAsStrings(self): |
|
54 | def testControllerMirrorsUserNSWithValuesAsStrings(self): | |
52 | code = """userns1=1;userns2=2""" |
|
55 | code = """userns1=1;userns2=2""" | |
53 | def testControllerUserNS(result): |
|
56 | def testControllerUserNS(result): | |
54 | self.assertEquals(self.controller.userNS['userns1'], 1) |
|
57 | self.assertEquals(self.controller.userNS['userns1'], 1) | |
55 | self.assertEquals(self.controller.userNS['userns2'], 2) |
|
58 | self.assertEquals(self.controller.userNS['userns2'], 2) | |
56 |
|
|
59 | ||
57 | self.controller.execute(code).addCallback(testControllerUserNS) |
|
60 | self.controller.execute(code).addCallback(testControllerUserNS) | |
58 |
|
|
61 | ||
59 |
|
|
62 | ||
60 | def testControllerInstantiatesIEngine(self): |
|
63 | def testControllerInstantiatesIEngine(self): | |
61 | self.assert_(es.IEngineBase.providedBy(self.controller.engine)) |
|
64 | self.assert_(es.IEngineBase.providedBy(self.controller.engine)) | |
62 |
|
|
65 | ||
63 | def testControllerCompletesToken(self): |
|
66 | def testControllerCompletesToken(self): | |
64 | code = """longNameVariable=10""" |
|
67 | code = """longNameVariable=10""" | |
65 | def testCompletes(result): |
|
68 | def testCompletes(result): | |
66 | self.assert_("longNameVariable" in result) |
|
69 | self.assert_("longNameVariable" in result) | |
67 |
|
|
70 | ||
68 | def testCompleteToken(result): |
|
71 | def testCompleteToken(result): | |
69 | self.controller.complete("longNa").addCallback(testCompletes) |
|
72 | self.controller.complete("longNa").addCallback(testCompletes) | |
70 |
|
|
73 | ||
71 | self.controller.execute(code).addCallback(testCompletes) |
|
74 | self.controller.execute(code).addCallback(testCompletes) | |
72 |
|
|
75 | ||
73 |
|
|
76 | ||
74 | def testCurrentIndent(self): |
|
77 | def testCurrentIndent(self): | |
75 | """test that current_indent_string returns current indent or None. |
|
78 | """test that current_indent_string returns current indent or None. | |
76 | Uses _indent_for_block for direct unit testing. |
|
79 | Uses _indent_for_block for direct unit testing. | |
77 | """ |
|
80 | """ | |
78 |
|
|
81 | ||
79 | self.controller.tabUsesSpaces = True |
|
82 | self.controller.tabUsesSpaces = True | |
80 | self.assert_(self.controller._indent_for_block("""a=3""") == None) |
|
83 | self.assert_(self.controller._indent_for_block("""a=3""") == None) | |
81 | self.assert_(self.controller._indent_for_block("") == None) |
|
84 | self.assert_(self.controller._indent_for_block("") == None) | |
82 | block = """def test():\n a=3""" |
|
85 | block = """def test():\n a=3""" | |
83 | self.assert_(self.controller._indent_for_block(block) == \ |
|
86 | self.assert_(self.controller._indent_for_block(block) == \ | |
84 | ' ' * self.controller.tabSpaces) |
|
87 | ' ' * self.controller.tabSpaces) | |
85 |
|
|
88 | ||
86 | block = """if(True):\n%sif(False):\n%spass""" % \ |
|
89 | block = """if(True):\n%sif(False):\n%spass""" % \ | |
87 | (' '*self.controller.tabSpaces, |
|
90 | (' '*self.controller.tabSpaces, | |
88 | 2*' '*self.controller.tabSpaces) |
|
91 | 2*' '*self.controller.tabSpaces) | |
89 | self.assert_(self.controller._indent_for_block(block) == \ |
|
92 | self.assert_(self.controller._indent_for_block(block) == \ | |
90 | 2*(' '*self.controller.tabSpaces)) |
|
93 | 2*(' '*self.controller.tabSpaces)) | |
91 |
|
|
94 |
@@ -28,7 +28,6 b' from zopeinterface import Interface, Attribute, implements, classProvides' | |||||
28 |
|
28 | |||
29 | from IPython.kernel.core.history import FrontEndHistory |
|
29 | from IPython.kernel.core.history import FrontEndHistory | |
30 | from IPython.kernel.core.util import Bunch |
|
30 | from IPython.kernel.core.util import Bunch | |
31 | from IPython.kernel.engineservice import IEngineCore |
|
|||
32 |
|
31 | |||
33 | ############################################################################## |
|
32 | ############################################################################## | |
34 | # TEMPORARY!!! fake configuration, while we decide whether to use tconfig or |
|
33 | # TEMPORARY!!! fake configuration, while we decide whether to use tconfig or |
@@ -16,9 +16,14 b' __docformat__ = "restructuredtext en"' | |||||
16 | #--------------------------------------------------------------------------- |
|
16 | #--------------------------------------------------------------------------- | |
17 |
|
17 | |||
18 | import unittest |
|
18 | import unittest | |
19 | from IPython.frontend.asyncfrontendbase import AsyncFrontEndBase |
|
19 | ||
20 | from IPython.frontend import frontendbase |
|
20 | try: | |
21 | from IPython.kernel.engineservice import EngineService |
|
21 | from IPython.frontend.asyncfrontendbase import AsyncFrontEndBase | |
|
22 | from IPython.frontend import frontendbase | |||
|
23 | from IPython.kernel.engineservice import EngineService | |||
|
24 | except ImportError: | |||
|
25 | import nose | |||
|
26 | raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap") | |||
22 |
|
27 | |||
23 | class FrontEndCallbackChecker(AsyncFrontEndBase): |
|
28 | class FrontEndCallbackChecker(AsyncFrontEndBase): | |
24 | """FrontEndBase subclass for checking callbacks""" |
|
29 | """FrontEndBase subclass for checking callbacks""" | |
@@ -28,11 +33,11 b' class FrontEndCallbackChecker(AsyncFrontEndBase):' | |||||
28 | self.updateCalled = False |
|
33 | self.updateCalled = False | |
29 | self.renderResultCalled = False |
|
34 | self.renderResultCalled = False | |
30 | self.renderErrorCalled = False |
|
35 | self.renderErrorCalled = False | |
31 |
|
|
36 | ||
32 | def update_cell_prompt(self, result, blockID=None): |
|
37 | def update_cell_prompt(self, result, blockID=None): | |
33 | self.updateCalled = True |
|
38 | self.updateCalled = True | |
34 | return result |
|
39 | return result | |
35 |
|
|
40 | ||
36 | def render_result(self, result): |
|
41 | def render_result(self, result): | |
37 | self.renderResultCalled = True |
|
42 | self.renderResultCalled = True | |
38 | return result |
|
43 | return result |
1 | NO CONTENT: modified file chmod 100755 => 100644 |
|
NO CONTENT: modified file chmod 100755 => 100644 |
1 | NO CONTENT: modified file chmod 100755 => 100644 |
|
NO CONTENT: modified file chmod 100755 => 100644 |
1 | NO CONTENT: modified file chmod 100755 => 100644 |
|
NO CONTENT: modified file chmod 100755 => 100644 |
1 | NO CONTENT: modified file chmod 100755 => 100644 |
|
NO CONTENT: modified file chmod 100755 => 100644 |
1 | NO CONTENT: modified file chmod 100755 => 100644 |
|
NO CONTENT: modified file chmod 100755 => 100644 |
@@ -20,7 +20,6 b' from twisted.internet import defer' | |||||
20 | from IPython.kernel import engineservice as es |
|
20 | from IPython.kernel import engineservice as es | |
21 | from IPython.kernel import multiengine as me |
|
21 | from IPython.kernel import multiengine as me | |
22 | from IPython.kernel import newserialized |
|
22 | from IPython.kernel import newserialized | |
23 | from IPython.kernel.error import NotDefined |
|
|||
24 | from IPython.testing import util |
|
23 | from IPython.testing import util | |
25 | from IPython.testing.parametric import parametric, Parametric |
|
24 | from IPython.testing.parametric import parametric, Parametric | |
26 | from IPython.kernel import newserialized |
|
25 | from IPython.kernel import newserialized |
@@ -30,14 +30,15 b' try:' | |||||
30 | from controllertest import IControllerCoreTestCase |
|
30 | from controllertest import IControllerCoreTestCase | |
31 | from IPython.testing.util import DeferredTestCase |
|
31 | from IPython.testing.util import DeferredTestCase | |
32 | except ImportError: |
|
32 | except ImportError: | |
33 | pass |
|
33 | import nose | |
34 | else: |
|
34 | raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap") | |
35 | class BasicControllerServiceTest(DeferredTestCase, |
|
35 | ||
36 | IControllerCoreTestCase): |
|
36 | class BasicControllerServiceTest(DeferredTestCase, | |
37 |
|
37 | IControllerCoreTestCase): | ||
38 | def setUp(self): |
|
38 | ||
39 | self.controller = ControllerService() |
|
39 | def setUp(self): | |
40 |
|
|
40 | self.controller = ControllerService() | |
41 |
|
41 | self.controller.startService() | ||
42 | def tearDown(self): |
|
42 | ||
43 | self.controller.stopService() |
|
43 | def tearDown(self): | |
|
44 | self.controller.stopService() |
@@ -37,56 +37,57 b' try:' | |||||
37 | IEngineSerializedTestCase, \ |
|
37 | IEngineSerializedTestCase, \ | |
38 | IEngineQueuedTestCase |
|
38 | IEngineQueuedTestCase | |
39 | except ImportError: |
|
39 | except ImportError: | |
40 | print "we got an error!!!" |
|
40 | import nose | |
41 | raise |
|
41 | raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap") | |
42 | else: |
|
42 | ||
43 | class EngineFCTest(DeferredTestCase, |
|
43 | ||
44 | IEngineCoreTestCase, |
|
44 | class EngineFCTest(DeferredTestCase, | |
45 |
|
|
45 | IEngineCoreTestCase, | |
46 |
|
|
46 | IEngineSerializedTestCase, | |
47 | ): |
|
47 | IEngineQueuedTestCase | |
48 |
|
48 | ): | ||
49 | zi.implements(IControllerBase) |
|
49 | ||
50 |
|
50 | zi.implements(IControllerBase) | ||
51 | def setUp(self): |
|
51 | ||
52 |
|
52 | def setUp(self): | ||
53 | # Start a server and append to self.servers |
|
53 | ||
54 | self.controller_reference = FCRemoteEngineRefFromService(self) |
|
54 | # Start a server and append to self.servers | |
55 | self.controller_tub = Tub() |
|
55 | self.controller_reference = FCRemoteEngineRefFromService(self) | |
56 | self.controller_tub.listenOn('tcp:10105:interface=127.0.0.1') |
|
56 | self.controller_tub = Tub() | |
57 |
|
|
57 | self.controller_tub.listenOn('tcp:10105:interface=127.0.0.1') | |
58 |
|
58 | self.controller_tub.setLocation('127.0.0.1:10105') | ||
59 | furl = self.controller_tub.registerReference(self.controller_reference) |
|
59 | ||
60 | self.controller_tub.startService() |
|
60 | furl = self.controller_tub.registerReference(self.controller_reference) | |
61 |
|
61 | self.controller_tub.startService() | ||
62 | # Start an EngineService and append to services/client |
|
62 | ||
63 | self.engine_service = es.EngineService() |
|
63 | # Start an EngineService and append to services/client | |
64 |
|
|
64 | self.engine_service = es.EngineService() | |
65 | self.engine_tub = Tub() |
|
65 | self.engine_service.startService() | |
66 |
|
|
66 | self.engine_tub = Tub() | |
67 | engine_connector = EngineConnector(self.engine_tub) |
|
67 | self.engine_tub.startService() | |
68 |
|
|
68 | engine_connector = EngineConnector(self.engine_tub) | |
69 | # This deferred doesn't fire until after register_engine has returned and |
|
69 | d = engine_connector.connect_to_controller(self.engine_service, furl) | |
70 | # thus, self.engine has been defined and the tets can proceed. |
|
70 | # This deferred doesn't fire until after register_engine has returned and | |
71 | return d |
|
71 | # thus, self.engine has been defined and the tets can proceed. | |
72 |
|
|
72 | return d | |
73 | def tearDown(self): |
|
73 | ||
74 | dlist = [] |
|
74 | def tearDown(self): | |
75 | # Shut down the engine |
|
75 | dlist = [] | |
76 | d = self.engine_tub.stopService() |
|
76 | # Shut down the engine | |
77 | dlist.append(d) |
|
77 | d = self.engine_tub.stopService() | |
78 | # Shut down the controller |
|
78 | dlist.append(d) | |
79 | d = self.controller_tub.stopService() |
|
79 | # Shut down the controller | |
80 | dlist.append(d) |
|
80 | d = self.controller_tub.stopService() | |
81 | return defer.DeferredList(dlist) |
|
81 | dlist.append(d) | |
82 |
|
82 | return defer.DeferredList(dlist) | ||
83 | #--------------------------------------------------------------------------- |
|
83 | ||
84 | # Make me look like a basic controller |
|
84 | #--------------------------------------------------------------------------- | |
85 | #--------------------------------------------------------------------------- |
|
85 | # Make me look like a basic controller | |
86 |
|
86 | #--------------------------------------------------------------------------- | ||
87 | def register_engine(self, engine_ref, id=None, ip=None, port=None, pid=None): |
|
87 | ||
88 | self.engine = IEngineQueued(IEngineBase(engine_ref)) |
|
88 | def register_engine(self, engine_ref, id=None, ip=None, port=None, pid=None): | |
89 | return {'id':id} |
|
89 | self.engine = IEngineQueued(IEngineBase(engine_ref)) | |
90 |
|
90 | return {'id':id} | ||
91 | def unregister_engine(self, id): |
|
91 | ||
92 | pass No newline at end of file |
|
92 | def unregister_engine(self, id): | |
|
93 | pass No newline at end of file |
@@ -35,44 +35,46 b' try:' | |||||
35 | IEngineQueuedTestCase, \ |
|
35 | IEngineQueuedTestCase, \ | |
36 | IEnginePropertiesTestCase |
|
36 | IEnginePropertiesTestCase | |
37 | except ImportError: |
|
37 | except ImportError: | |
38 | pass |
|
38 | import nose | |
39 | else: |
|
39 | raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap") | |
40 | class BasicEngineServiceTest(DeferredTestCase, |
|
40 | ||
41 | IEngineCoreTestCase, |
|
41 | ||
42 | IEngineSerializedTestCase, |
|
42 | class BasicEngineServiceTest(DeferredTestCase, | |
43 |
|
|
43 | IEngineCoreTestCase, | |
44 |
|
44 | IEngineSerializedTestCase, | ||
45 | def setUp(self): |
|
45 | IEnginePropertiesTestCase): | |
46 | self.engine = es.EngineService() |
|
46 | ||
47 | self.engine.startService() |
|
47 | def setUp(self): | |
48 |
|
48 | self.engine = es.EngineService() | ||
49 | def tearDown(self): |
|
49 | self.engine.startService() | |
50 | return self.engine.stopService() |
|
50 | ||
51 |
|
51 | def tearDown(self): | ||
52 | class ThreadedEngineServiceTest(DeferredTestCase, |
|
52 | return self.engine.stopService() | |
53 | IEngineCoreTestCase, |
|
53 | ||
54 | IEngineSerializedTestCase, |
|
54 | class ThreadedEngineServiceTest(DeferredTestCase, | |
55 |
|
|
55 | IEngineCoreTestCase, | |
56 |
|
56 | IEngineSerializedTestCase, | ||
57 | def setUp(self): |
|
57 | IEnginePropertiesTestCase): | |
58 | self.engine = es.ThreadedEngineService() |
|
58 | ||
59 | self.engine.startService() |
|
59 | def setUp(self): | |
|
60 | self.engine = es.ThreadedEngineService() | |||
|
61 | self.engine.startService() | |||
|
62 | ||||
|
63 | def tearDown(self): | |||
|
64 | return self.engine.stopService() | |||
|
65 | ||||
|
66 | class QueuedEngineServiceTest(DeferredTestCase, | |||
|
67 | IEngineCoreTestCase, | |||
|
68 | IEngineSerializedTestCase, | |||
|
69 | IEnginePropertiesTestCase, | |||
|
70 | IEngineQueuedTestCase): | |||
|
71 | ||||
|
72 | def setUp(self): | |||
|
73 | self.rawEngine = es.EngineService() | |||
|
74 | self.rawEngine.startService() | |||
|
75 | self.engine = es.IEngineQueued(self.rawEngine) | |||
60 |
|
76 | |||
61 |
|
|
77 | def tearDown(self): | |
62 |
|
|
78 | return self.rawEngine.stopService() | |
63 |
|
79 | |||
64 | class QueuedEngineServiceTest(DeferredTestCase, |
|
80 | ||
65 | IEngineCoreTestCase, |
|
|||
66 | IEngineSerializedTestCase, |
|
|||
67 | IEnginePropertiesTestCase, |
|
|||
68 | IEngineQueuedTestCase): |
|
|||
69 |
|
||||
70 | def setUp(self): |
|
|||
71 | self.rawEngine = es.EngineService() |
|
|||
72 | self.rawEngine.startService() |
|
|||
73 | self.engine = es.IEngineQueued(self.rawEngine) |
|
|||
74 |
|
||||
75 | def tearDown(self): |
|
|||
76 | return self.rawEngine.stopService() |
|
|||
77 |
|
||||
78 |
|
@@ -23,32 +23,34 b' try:' | |||||
23 | from IPython.kernel.tests.multienginetest import (IMultiEngineTestCase, |
|
23 | from IPython.kernel.tests.multienginetest import (IMultiEngineTestCase, | |
24 | ISynchronousMultiEngineTestCase) |
|
24 | ISynchronousMultiEngineTestCase) | |
25 | except ImportError: |
|
25 | except ImportError: | |
26 | pass |
|
26 | import nose | |
27 | else: |
|
27 | raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap") | |
28 | class BasicMultiEngineTestCase(DeferredTestCase, IMultiEngineTestCase): |
|
28 | ||
|
29 | ||||
|
30 | class BasicMultiEngineTestCase(DeferredTestCase, IMultiEngineTestCase): | |||
|
31 | ||||
|
32 | def setUp(self): | |||
|
33 | self.controller = ControllerService() | |||
|
34 | self.controller.startService() | |||
|
35 | self.multiengine = me.IMultiEngine(self.controller) | |||
|
36 | self.engines = [] | |||
29 |
|
37 | |||
30 |
|
|
38 | def tearDown(self): | |
31 |
|
|
39 | self.controller.stopService() | |
32 | self.controller.startService() |
|
40 | for e in self.engines: | |
33 | self.multiengine = me.IMultiEngine(self.controller) |
|
41 | e.stopService() | |
34 | self.engines = [] |
|
42 | ||
35 |
|
43 | |||
36 | def tearDown(self): |
|
44 | class SynchronousMultiEngineTestCase(DeferredTestCase, ISynchronousMultiEngineTestCase): | |
37 | self.controller.stopService() |
|
45 | ||
38 | for e in self.engines: |
|
46 | def setUp(self): | |
39 | e.stopService() |
|
47 | self.controller = ControllerService() | |
40 |
|
48 | self.controller.startService() | ||
41 |
|
49 | self.multiengine = me.ISynchronousMultiEngine(me.IMultiEngine(self.controller)) | ||
42 | class SynchronousMultiEngineTestCase(DeferredTestCase, ISynchronousMultiEngineTestCase): |
|
50 | self.engines = [] | |
43 |
|
51 | |||
44 |
|
|
52 | def tearDown(self): | |
45 |
|
|
53 | self.controller.stopService() | |
46 | self.controller.startService() |
|
54 | for e in self.engines: | |
47 | self.multiengine = me.ISynchronousMultiEngine(me.IMultiEngine(self.controller)) |
|
55 | e.stopService() | |
48 | self.engines = [] |
|
|||
49 |
|
||||
50 | def tearDown(self): |
|
|||
51 | self.controller.stopService() |
|
|||
52 | for e in self.engines: |
|
|||
53 | e.stopService() |
|
|||
54 |
|
56 |
@@ -30,115 +30,115 b' try:' | |||||
30 | from IPython.kernel.error import CompositeError |
|
30 | from IPython.kernel.error import CompositeError | |
31 | from IPython.kernel.util import printer |
|
31 | from IPython.kernel.util import printer | |
32 | except ImportError: |
|
32 | except ImportError: | |
33 | pass |
|
33 | import nose | |
34 | else: |
|
34 | raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap") | |
35 |
|
35 | |||
36 |
|
|
36 | def _raise_it(f): | |
37 |
|
|
37 | try: | |
38 |
|
|
38 | f.raiseException() | |
39 |
|
|
39 | except CompositeError, e: | |
40 |
|
|
40 | e.raise_exception() | |
|
41 | ||||
|
42 | ||||
|
43 | class FullSynchronousMultiEngineTestCase(DeferredTestCase, IFullSynchronousMultiEngineTestCase): | |||
|
44 | ||||
|
45 | def setUp(self): | |||
41 |
|
46 | |||
|
47 | self.engines = [] | |||
|
48 | ||||
|
49 | self.controller = ControllerService() | |||
|
50 | self.controller.startService() | |||
|
51 | self.imultiengine = IMultiEngine(self.controller) | |||
|
52 | self.mec_referenceable = IFCSynchronousMultiEngine(self.imultiengine) | |||
|
53 | ||||
|
54 | self.controller_tub = Tub() | |||
|
55 | self.controller_tub.listenOn('tcp:10105:interface=127.0.0.1') | |||
|
56 | self.controller_tub.setLocation('127.0.0.1:10105') | |||
42 |
|
57 | |||
43 | class FullSynchronousMultiEngineTestCase(DeferredTestCase, IFullSynchronousMultiEngineTestCase): |
|
58 | furl = self.controller_tub.registerReference(self.mec_referenceable) | |
|
59 | self.controller_tub.startService() | |||
44 |
|
60 | |||
45 | def setUp(self): |
|
61 | self.client_tub = ClientConnector() | |
46 |
|
62 | d = self.client_tub.get_multiengine_client(furl) | ||
47 | self.engines = [] |
|
63 | d.addCallback(self.handle_got_client) | |
48 |
|
64 | return d | ||
49 | self.controller = ControllerService() |
|
|||
50 | self.controller.startService() |
|
|||
51 | self.imultiengine = IMultiEngine(self.controller) |
|
|||
52 | self.mec_referenceable = IFCSynchronousMultiEngine(self.imultiengine) |
|
|||
53 |
|
||||
54 | self.controller_tub = Tub() |
|
|||
55 | self.controller_tub.listenOn('tcp:10105:interface=127.0.0.1') |
|
|||
56 | self.controller_tub.setLocation('127.0.0.1:10105') |
|
|||
57 |
|
||||
58 | furl = self.controller_tub.registerReference(self.mec_referenceable) |
|
|||
59 | self.controller_tub.startService() |
|
|||
60 |
|
||||
61 | self.client_tub = ClientConnector() |
|
|||
62 | d = self.client_tub.get_multiengine_client(furl) |
|
|||
63 | d.addCallback(self.handle_got_client) |
|
|||
64 | return d |
|
|||
65 |
|
||||
66 | def handle_got_client(self, client): |
|
|||
67 | self.multiengine = client |
|
|||
68 |
|
65 | |||
69 | def tearDown(self): |
|
66 | def handle_got_client(self, client): | |
70 | dlist = [] |
|
67 | self.multiengine = client | |
71 | # Shut down the multiengine client |
|
68 | ||
72 | d = self.client_tub.tub.stopService() |
|
69 | def tearDown(self): | |
73 | dlist.append(d) |
|
70 | dlist = [] | |
74 |
|
|
71 | # Shut down the multiengine client | |
75 | for e in self.engines: |
|
72 | d = self.client_tub.tub.stopService() | |
76 | e.stopService() |
|
73 | dlist.append(d) | |
77 |
|
|
74 | # Shut down the engines | |
78 | d = self.controller_tub.stopService() |
|
75 | for e in self.engines: | |
79 |
|
|
76 | e.stopService() | |
80 | dlist.append(d) |
|
77 | # Shut down the controller | |
81 | return defer.DeferredList(dlist) |
|
78 | d = self.controller_tub.stopService() | |
|
79 | d.addBoth(lambda _: self.controller.stopService()) | |||
|
80 | dlist.append(d) | |||
|
81 | return defer.DeferredList(dlist) | |||
82 |
|
82 | |||
83 |
|
|
83 | def test_mapper(self): | |
84 |
|
|
84 | self.addEngine(4) | |
85 |
|
|
85 | m = self.multiengine.mapper() | |
86 |
|
|
86 | self.assertEquals(m.multiengine,self.multiengine) | |
87 |
|
|
87 | self.assertEquals(m.dist,'b') | |
88 |
|
|
88 | self.assertEquals(m.targets,'all') | |
89 |
|
|
89 | self.assertEquals(m.block,True) | |
90 |
|
|
90 | ||
91 |
|
|
91 | def test_map_default(self): | |
92 |
|
|
92 | self.addEngine(4) | |
93 |
|
|
93 | m = self.multiengine.mapper() | |
94 |
|
|
94 | d = m.map(lambda x: 2*x, range(10)) | |
95 |
|
|
95 | d.addCallback(lambda r: self.assertEquals(r,[2*x for x in range(10)])) | |
96 |
|
|
96 | d.addCallback(lambda _: self.multiengine.map(lambda x: 2*x, range(10))) | |
97 |
|
|
97 | d.addCallback(lambda r: self.assertEquals(r,[2*x for x in range(10)])) | |
98 |
|
|
98 | return d | |
99 |
|
|
99 | ||
100 |
|
|
100 | def test_map_noblock(self): | |
101 |
|
|
101 | self.addEngine(4) | |
102 |
|
|
102 | m = self.multiengine.mapper(block=False) | |
103 |
|
|
103 | d = m.map(lambda x: 2*x, range(10)) | |
104 |
|
|
104 | d.addCallback(lambda did: self.multiengine.get_pending_deferred(did, True)) | |
105 |
|
|
105 | d.addCallback(lambda r: self.assertEquals(r,[2*x for x in range(10)])) | |
106 |
|
|
106 | return d | |
107 |
|
|
107 | ||
108 |
|
|
108 | def test_mapper_fail(self): | |
109 |
|
|
109 | self.addEngine(4) | |
110 |
|
|
110 | m = self.multiengine.mapper() | |
111 |
|
|
111 | d = m.map(lambda x: 1/0, range(10)) | |
112 |
|
|
112 | d.addBoth(lambda f: self.assertRaises(ZeroDivisionError, _raise_it, f)) | |
113 |
|
|
113 | return d | |
114 |
|
|
114 | ||
115 |
|
|
115 | def test_parallel(self): | |
116 |
|
|
116 | self.addEngine(4) | |
117 |
|
|
117 | p = self.multiengine.parallel() | |
118 |
|
|
118 | self.assert_(isinstance(p, ParallelFunction)) | |
119 |
|
|
119 | @p | |
120 |
|
|
120 | def f(x): return 2*x | |
121 |
|
|
121 | d = f(range(10)) | |
122 |
|
|
122 | d.addCallback(lambda r: self.assertEquals(r,[2*x for x in range(10)])) | |
123 |
|
|
123 | return d | |
124 |
|
|
124 | ||
125 |
|
|
125 | def test_parallel_noblock(self): | |
126 |
|
|
126 | self.addEngine(1) | |
127 |
|
|
127 | p = self.multiengine.parallel(block=False) | |
128 |
|
|
128 | self.assert_(isinstance(p, ParallelFunction)) | |
129 |
|
|
129 | @p | |
130 |
|
|
130 | def f(x): return 2*x | |
131 |
|
|
131 | d = f(range(10)) | |
132 |
|
|
132 | d.addCallback(lambda did: self.multiengine.get_pending_deferred(did, True)) | |
133 |
|
|
133 | d.addCallback(lambda r: self.assertEquals(r,[2*x for x in range(10)])) | |
134 |
|
|
134 | return d | |
135 |
|
|
135 | ||
136 |
|
|
136 | def test_parallel_fail(self): | |
137 |
|
|
137 | self.addEngine(4) | |
138 |
|
|
138 | p = self.multiengine.parallel() | |
139 |
|
|
139 | self.assert_(isinstance(p, ParallelFunction)) | |
140 |
|
|
140 | @p | |
141 |
|
|
141 | def f(x): return 1/0 | |
142 |
|
|
142 | d = f(range(10)) | |
143 |
|
|
143 | d.addBoth(lambda f: self.assertRaises(ZeroDivisionError, _raise_it, f)) | |
144 |
|
|
144 | return d No newline at end of file |
@@ -28,75 +28,75 b' try:' | |||||
28 | SerializeIt, \ |
|
28 | SerializeIt, \ | |
29 | UnSerializeIt |
|
29 | UnSerializeIt | |
30 | except ImportError: |
|
30 | except ImportError: | |
31 | pass |
|
31 | import nose | |
32 | else: |
|
32 | raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap") | |
33 | #------------------------------------------------------------------------------- |
|
33 | ||
34 | # Tests |
|
34 | #------------------------------------------------------------------------------- | |
35 | #------------------------------------------------------------------------------- |
|
35 | # Tests | |
|
36 | #------------------------------------------------------------------------------- | |||
|
37 | ||||
|
38 | class SerializedTestCase(unittest.TestCase): | |||
|
39 | ||||
|
40 | def setUp(self): | |||
|
41 | pass | |||
36 |
|
42 | |||
37 | class SerializedTestCase(unittest.TestCase): |
|
43 | def tearDown(self): | |
|
44 | pass | |||
38 |
|
45 | |||
39 | def setUp(self): |
|
46 | def testSerializedInterfaces(self): | |
40 | pass |
|
|||
41 |
|
||||
42 | def tearDown(self): |
|
|||
43 | pass |
|
|||
44 |
|
||||
45 | def testSerializedInterfaces(self): |
|
|||
46 |
|
47 | |||
47 |
|
|
48 | us = UnSerialized({'a':10, 'b':range(10)}) | |
48 |
|
|
49 | s = ISerialized(us) | |
49 |
|
|
50 | uss = IUnSerialized(s) | |
50 |
|
|
51 | self.assert_(ISerialized.providedBy(s)) | |
51 |
|
|
52 | self.assert_(IUnSerialized.providedBy(us)) | |
52 |
|
|
53 | self.assert_(IUnSerialized.providedBy(uss)) | |
53 |
|
|
54 | for m in list(ISerialized): | |
54 |
|
|
55 | self.assert_(hasattr(s, m)) | |
55 |
|
|
56 | for m in list(IUnSerialized): | |
56 |
|
|
57 | self.assert_(hasattr(us, m)) | |
57 |
|
|
58 | for m in list(IUnSerialized): | |
58 |
|
|
59 | self.assert_(hasattr(uss, m)) | |
59 |
|
60 | |||
60 |
|
|
61 | def testPickleSerialized(self): | |
61 |
|
|
62 | obj = {'a':1.45345, 'b':'asdfsdf', 'c':10000L} | |
62 |
|
|
63 | original = UnSerialized(obj) | |
63 |
|
|
64 | originalSer = ISerialized(original) | |
64 |
|
|
65 | firstData = originalSer.getData() | |
65 |
|
|
66 | firstTD = originalSer.getTypeDescriptor() | |
66 |
|
|
67 | firstMD = originalSer.getMetadata() | |
67 |
|
|
68 | self.assert_(firstTD == 'pickle') | |
68 |
|
|
69 | self.assert_(firstMD == {}) | |
69 |
|
|
70 | unSerialized = IUnSerialized(originalSer) | |
70 |
|
|
71 | secondObj = unSerialized.getObject() | |
71 |
|
|
72 | for k, v in secondObj.iteritems(): | |
72 |
|
|
73 | self.assert_(obj[k] == v) | |
73 |
|
|
74 | secondSer = ISerialized(UnSerialized(secondObj)) | |
74 |
|
|
75 | self.assert_(firstData == secondSer.getData()) | |
75 |
|
|
76 | self.assert_(firstTD == secondSer.getTypeDescriptor() ) | |
76 |
|
|
77 | self.assert_(firstMD == secondSer.getMetadata()) | |
|
78 | ||||
|
79 | def testNDArraySerialized(self): | |||
|
80 | try: | |||
|
81 | import numpy | |||
|
82 | except ImportError: | |||
|
83 | pass | |||
|
84 | else: | |||
|
85 | a = numpy.linspace(0.0, 1.0, 1000) | |||
|
86 | unSer1 = UnSerialized(a) | |||
|
87 | ser1 = ISerialized(unSer1) | |||
|
88 | td = ser1.getTypeDescriptor() | |||
|
89 | self.assert_(td == 'ndarray') | |||
|
90 | md = ser1.getMetadata() | |||
|
91 | self.assert_(md['shape'] == a.shape) | |||
|
92 | self.assert_(md['dtype'] == a.dtype.str) | |||
|
93 | buff = ser1.getData() | |||
|
94 | self.assert_(buff == numpy.getbuffer(a)) | |||
|
95 | s = Serialized(buff, td, md) | |||
|
96 | us = IUnSerialized(s) | |||
|
97 | final = us.getObject() | |||
|
98 | self.assert_(numpy.getbuffer(a) == numpy.getbuffer(final)) | |||
|
99 | self.assert_(a.dtype.str == final.dtype.str) | |||
|
100 | self.assert_(a.shape == final.shape) | |||
|
101 | ||||
77 |
|
102 | |||
78 | def testNDArraySerialized(self): |
|
|||
79 | try: |
|
|||
80 | import numpy |
|
|||
81 | except ImportError: |
|
|||
82 | pass |
|
|||
83 | else: |
|
|||
84 | a = numpy.linspace(0.0, 1.0, 1000) |
|
|||
85 | unSer1 = UnSerialized(a) |
|
|||
86 | ser1 = ISerialized(unSer1) |
|
|||
87 | td = ser1.getTypeDescriptor() |
|
|||
88 | self.assert_(td == 'ndarray') |
|
|||
89 | md = ser1.getMetadata() |
|
|||
90 | self.assert_(md['shape'] == a.shape) |
|
|||
91 | self.assert_(md['dtype'] == a.dtype.str) |
|
|||
92 | buff = ser1.getData() |
|
|||
93 | self.assert_(buff == numpy.getbuffer(a)) |
|
|||
94 | s = Serialized(buff, td, md) |
|
|||
95 | us = IUnSerialized(s) |
|
|||
96 | final = us.getObject() |
|
|||
97 | self.assert_(numpy.getbuffer(a) == numpy.getbuffer(final)) |
|
|||
98 | self.assert_(a.dtype.str == final.dtype.str) |
|
|||
99 | self.assert_(a.shape == final.shape) |
|
|||
100 |
|
||||
101 |
|
||||
102 | No newline at end of file |
|
@@ -25,162 +25,162 b' try:' | |||||
25 | from IPython.kernel import error |
|
25 | from IPython.kernel import error | |
26 | from IPython.kernel.util import printer |
|
26 | from IPython.kernel.util import printer | |
27 | except ImportError: |
|
27 | except ImportError: | |
28 | pass |
|
28 | import nose | |
29 | else: |
|
29 | raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap") | |
30 |
|
30 | |||
31 |
|
|
31 | class Foo(object): | |
32 |
|
||||
33 | def bar(self, bahz): |
|
|||
34 | return defer.succeed('blahblah: %s' % bahz) |
|
|||
35 |
|
32 | |||
36 | class TwoPhaseFoo(pd.PendingDeferredManager): |
|
33 | def bar(self, bahz): | |
37 |
|
34 | return defer.succeed('blahblah: %s' % bahz) | ||
38 | def __init__(self, foo): |
|
|||
39 | self.foo = foo |
|
|||
40 | pd.PendingDeferredManager.__init__(self) |
|
|||
41 |
|
35 | |||
42 | @pd.two_phase |
|
36 | class TwoPhaseFoo(pd.PendingDeferredManager): | |
43 | def bar(self, bahz): |
|
|||
44 | return self.foo.bar(bahz) |
|
|||
45 |
|
37 | |||
46 | class PendingDeferredManagerTest(DeferredTestCase): |
|
38 | def __init__(self, foo): | |
47 |
|
39 | self.foo = foo | ||
48 | def setUp(self): |
|
40 | pd.PendingDeferredManager.__init__(self) | |
49 | self.pdm = pd.PendingDeferredManager() |
|
|||
50 |
|
||||
51 | def tearDown(self): |
|
|||
52 | pass |
|
|||
53 |
|
||||
54 | def testBasic(self): |
|
|||
55 | dDict = {} |
|
|||
56 | # Create 10 deferreds and save them |
|
|||
57 | for i in range(10): |
|
|||
58 | d = defer.Deferred() |
|
|||
59 | did = self.pdm.save_pending_deferred(d) |
|
|||
60 | dDict[did] = d |
|
|||
61 | # Make sure they are begin saved |
|
|||
62 | for k in dDict.keys(): |
|
|||
63 | self.assert_(self.pdm.quick_has_id(k)) |
|
|||
64 | # Get the pending deferred (block=True), then callback with 'foo' and compare |
|
|||
65 | for did in dDict.keys()[0:5]: |
|
|||
66 | d = self.pdm.get_pending_deferred(did,block=True) |
|
|||
67 | dDict[did].callback('foo') |
|
|||
68 | d.addCallback(lambda r: self.assert_(r=='foo')) |
|
|||
69 | # Get the pending deferreds with (block=False) and make sure ResultNotCompleted is raised |
|
|||
70 | for did in dDict.keys()[5:10]: |
|
|||
71 | d = self.pdm.get_pending_deferred(did,block=False) |
|
|||
72 | d.addErrback(lambda f: self.assertRaises(error.ResultNotCompleted, f.raiseException)) |
|
|||
73 | # Now callback the last 5, get them and compare. |
|
|||
74 | for did in dDict.keys()[5:10]: |
|
|||
75 | dDict[did].callback('foo') |
|
|||
76 | d = self.pdm.get_pending_deferred(did,block=False) |
|
|||
77 | d.addCallback(lambda r: self.assert_(r=='foo')) |
|
|||
78 |
|
||||
79 | def test_save_then_delete(self): |
|
|||
80 | d = defer.Deferred() |
|
|||
81 | did = self.pdm.save_pending_deferred(d) |
|
|||
82 | self.assert_(self.pdm.quick_has_id(did)) |
|
|||
83 | self.pdm.delete_pending_deferred(did) |
|
|||
84 | self.assert_(not self.pdm.quick_has_id(did)) |
|
|||
85 |
|
||||
86 | def test_save_get_delete(self): |
|
|||
87 | d = defer.Deferred() |
|
|||
88 | did = self.pdm.save_pending_deferred(d) |
|
|||
89 | d2 = self.pdm.get_pending_deferred(did,True) |
|
|||
90 | d2.addErrback(lambda f: self.assertRaises(error.AbortedPendingDeferredError, f.raiseException)) |
|
|||
91 | self.pdm.delete_pending_deferred(did) |
|
|||
92 | return d2 |
|
|||
93 |
|
||||
94 | def test_double_get(self): |
|
|||
95 | d = defer.Deferred() |
|
|||
96 | did = self.pdm.save_pending_deferred(d) |
|
|||
97 | d2 = self.pdm.get_pending_deferred(did,True) |
|
|||
98 | d3 = self.pdm.get_pending_deferred(did,True) |
|
|||
99 | d3.addErrback(lambda f: self.assertRaises(error.InvalidDeferredID, f.raiseException)) |
|
|||
100 |
|
||||
101 | def test_get_after_callback(self): |
|
|||
102 | d = defer.Deferred() |
|
|||
103 | did = self.pdm.save_pending_deferred(d) |
|
|||
104 | d.callback('foo') |
|
|||
105 | d2 = self.pdm.get_pending_deferred(did,True) |
|
|||
106 | d2.addCallback(lambda r: self.assertEquals(r,'foo')) |
|
|||
107 | self.assert_(not self.pdm.quick_has_id(did)) |
|
|||
108 |
|
41 | |||
109 | def test_get_before_callback(self): |
|
42 | @pd.two_phase | |
110 | d = defer.Deferred() |
|
43 | def bar(self, bahz): | |
111 | did = self.pdm.save_pending_deferred(d) |
|
44 | return self.foo.bar(bahz) | |
112 | d2 = self.pdm.get_pending_deferred(did,True) |
|
|||
113 | d.callback('foo') |
|
|||
114 | d2.addCallback(lambda r: self.assertEquals(r,'foo')) |
|
|||
115 | self.assert_(not self.pdm.quick_has_id(did)) |
|
|||
116 | d = defer.Deferred() |
|
|||
117 | did = self.pdm.save_pending_deferred(d) |
|
|||
118 | d2 = self.pdm.get_pending_deferred(did,True) |
|
|||
119 | d2.addCallback(lambda r: self.assertEquals(r,'foo')) |
|
|||
120 | d.callback('foo') |
|
|||
121 | self.assert_(not self.pdm.quick_has_id(did)) |
|
|||
122 |
|
||||
123 | def test_get_after_errback(self): |
|
|||
124 | class MyError(Exception): |
|
|||
125 | pass |
|
|||
126 | d = defer.Deferred() |
|
|||
127 | did = self.pdm.save_pending_deferred(d) |
|
|||
128 | d.errback(failure.Failure(MyError('foo'))) |
|
|||
129 | d2 = self.pdm.get_pending_deferred(did,True) |
|
|||
130 | d2.addErrback(lambda f: self.assertRaises(MyError, f.raiseException)) |
|
|||
131 | self.assert_(not self.pdm.quick_has_id(did)) |
|
|||
132 |
|
||||
133 | def test_get_before_errback(self): |
|
|||
134 | class MyError(Exception): |
|
|||
135 | pass |
|
|||
136 | d = defer.Deferred() |
|
|||
137 | did = self.pdm.save_pending_deferred(d) |
|
|||
138 | d2 = self.pdm.get_pending_deferred(did,True) |
|
|||
139 | d.errback(failure.Failure(MyError('foo'))) |
|
|||
140 | d2.addErrback(lambda f: self.assertRaises(MyError, f.raiseException)) |
|
|||
141 | self.assert_(not self.pdm.quick_has_id(did)) |
|
|||
142 | d = defer.Deferred() |
|
|||
143 | did = self.pdm.save_pending_deferred(d) |
|
|||
144 | d2 = self.pdm.get_pending_deferred(did,True) |
|
|||
145 | d2.addErrback(lambda f: self.assertRaises(MyError, f.raiseException)) |
|
|||
146 | d.errback(failure.Failure(MyError('foo'))) |
|
|||
147 | self.assert_(not self.pdm.quick_has_id(did)) |
|
|||
148 |
|
||||
149 | def test_noresult_noblock(self): |
|
|||
150 | d = defer.Deferred() |
|
|||
151 | did = self.pdm.save_pending_deferred(d) |
|
|||
152 | d2 = self.pdm.get_pending_deferred(did,False) |
|
|||
153 | d2.addErrback(lambda f: self.assertRaises(error.ResultNotCompleted, f.raiseException)) |
|
|||
154 |
|
45 | |||
155 | def test_with_callbacks(self): |
|
46 | class PendingDeferredManagerTest(DeferredTestCase): | |
156 | d = defer.Deferred() |
|
47 | ||
157 | d.addCallback(lambda r: r+' foo') |
|
48 | def setUp(self): | |
158 | d.addCallback(lambda r: r+' bar') |
|
49 | self.pdm = pd.PendingDeferredManager() | |
159 | did = self.pdm.save_pending_deferred(d) |
|
|||
160 | d2 = self.pdm.get_pending_deferred(did,True) |
|
|||
161 | d.callback('bam') |
|
|||
162 | d2.addCallback(lambda r: self.assertEquals(r,'bam foo bar')) |
|
|||
163 |
|
50 | |||
164 |
|
|
51 | def tearDown(self): | |
165 | class MyError(Exception): |
|
52 | pass | |
166 | pass |
|
53 | ||
|
54 | def testBasic(self): | |||
|
55 | dDict = {} | |||
|
56 | # Create 10 deferreds and save them | |||
|
57 | for i in range(10): | |||
167 | d = defer.Deferred() |
|
58 | d = defer.Deferred() | |
168 | d.addCallback(lambda r: 'foo') |
|
|||
169 | d.addErrback(lambda f: 'caught error') |
|
|||
170 | did = self.pdm.save_pending_deferred(d) |
|
59 | did = self.pdm.save_pending_deferred(d) | |
171 | d2 = self.pdm.get_pending_deferred(did,True) |
|
60 | dDict[did] = d | |
172 | d.errback(failure.Failure(MyError('bam'))) |
|
61 | # Make sure they are begin saved | |
173 | d2.addErrback(lambda f: self.assertRaises(MyError, f.raiseException)) |
|
62 | for k in dDict.keys(): | |
|
63 | self.assert_(self.pdm.quick_has_id(k)) | |||
|
64 | # Get the pending deferred (block=True), then callback with 'foo' and compare | |||
|
65 | for did in dDict.keys()[0:5]: | |||
|
66 | d = self.pdm.get_pending_deferred(did,block=True) | |||
|
67 | dDict[did].callback('foo') | |||
|
68 | d.addCallback(lambda r: self.assert_(r=='foo')) | |||
|
69 | # Get the pending deferreds with (block=False) and make sure ResultNotCompleted is raised | |||
|
70 | for did in dDict.keys()[5:10]: | |||
|
71 | d = self.pdm.get_pending_deferred(did,block=False) | |||
|
72 | d.addErrback(lambda f: self.assertRaises(error.ResultNotCompleted, f.raiseException)) | |||
|
73 | # Now callback the last 5, get them and compare. | |||
|
74 | for did in dDict.keys()[5:10]: | |||
|
75 | dDict[did].callback('foo') | |||
|
76 | d = self.pdm.get_pending_deferred(did,block=False) | |||
|
77 | d.addCallback(lambda r: self.assert_(r=='foo')) | |||
|
78 | ||||
|
79 | def test_save_then_delete(self): | |||
|
80 | d = defer.Deferred() | |||
|
81 | did = self.pdm.save_pending_deferred(d) | |||
|
82 | self.assert_(self.pdm.quick_has_id(did)) | |||
|
83 | self.pdm.delete_pending_deferred(did) | |||
|
84 | self.assert_(not self.pdm.quick_has_id(did)) | |||
|
85 | ||||
|
86 | def test_save_get_delete(self): | |||
|
87 | d = defer.Deferred() | |||
|
88 | did = self.pdm.save_pending_deferred(d) | |||
|
89 | d2 = self.pdm.get_pending_deferred(did,True) | |||
|
90 | d2.addErrback(lambda f: self.assertRaises(error.AbortedPendingDeferredError, f.raiseException)) | |||
|
91 | self.pdm.delete_pending_deferred(did) | |||
|
92 | return d2 | |||
|
93 | ||||
|
94 | def test_double_get(self): | |||
|
95 | d = defer.Deferred() | |||
|
96 | did = self.pdm.save_pending_deferred(d) | |||
|
97 | d2 = self.pdm.get_pending_deferred(did,True) | |||
|
98 | d3 = self.pdm.get_pending_deferred(did,True) | |||
|
99 | d3.addErrback(lambda f: self.assertRaises(error.InvalidDeferredID, f.raiseException)) | |||
|
100 | ||||
|
101 | def test_get_after_callback(self): | |||
|
102 | d = defer.Deferred() | |||
|
103 | did = self.pdm.save_pending_deferred(d) | |||
|
104 | d.callback('foo') | |||
|
105 | d2 = self.pdm.get_pending_deferred(did,True) | |||
|
106 | d2.addCallback(lambda r: self.assertEquals(r,'foo')) | |||
|
107 | self.assert_(not self.pdm.quick_has_id(did)) | |||
|
108 | ||||
|
109 | def test_get_before_callback(self): | |||
|
110 | d = defer.Deferred() | |||
|
111 | did = self.pdm.save_pending_deferred(d) | |||
|
112 | d2 = self.pdm.get_pending_deferred(did,True) | |||
|
113 | d.callback('foo') | |||
|
114 | d2.addCallback(lambda r: self.assertEquals(r,'foo')) | |||
|
115 | self.assert_(not self.pdm.quick_has_id(did)) | |||
|
116 | d = defer.Deferred() | |||
|
117 | did = self.pdm.save_pending_deferred(d) | |||
|
118 | d2 = self.pdm.get_pending_deferred(did,True) | |||
|
119 | d2.addCallback(lambda r: self.assertEquals(r,'foo')) | |||
|
120 | d.callback('foo') | |||
|
121 | self.assert_(not self.pdm.quick_has_id(did)) | |||
|
122 | ||||
|
123 | def test_get_after_errback(self): | |||
|
124 | class MyError(Exception): | |||
|
125 | pass | |||
|
126 | d = defer.Deferred() | |||
|
127 | did = self.pdm.save_pending_deferred(d) | |||
|
128 | d.errback(failure.Failure(MyError('foo'))) | |||
|
129 | d2 = self.pdm.get_pending_deferred(did,True) | |||
|
130 | d2.addErrback(lambda f: self.assertRaises(MyError, f.raiseException)) | |||
|
131 | self.assert_(not self.pdm.quick_has_id(did)) | |||
|
132 | ||||
|
133 | def test_get_before_errback(self): | |||
|
134 | class MyError(Exception): | |||
|
135 | pass | |||
|
136 | d = defer.Deferred() | |||
|
137 | did = self.pdm.save_pending_deferred(d) | |||
|
138 | d2 = self.pdm.get_pending_deferred(did,True) | |||
|
139 | d.errback(failure.Failure(MyError('foo'))) | |||
|
140 | d2.addErrback(lambda f: self.assertRaises(MyError, f.raiseException)) | |||
|
141 | self.assert_(not self.pdm.quick_has_id(did)) | |||
|
142 | d = defer.Deferred() | |||
|
143 | did = self.pdm.save_pending_deferred(d) | |||
|
144 | d2 = self.pdm.get_pending_deferred(did,True) | |||
|
145 | d2.addErrback(lambda f: self.assertRaises(MyError, f.raiseException)) | |||
|
146 | d.errback(failure.Failure(MyError('foo'))) | |||
|
147 | self.assert_(not self.pdm.quick_has_id(did)) | |||
174 |
|
148 | |||
175 |
|
|
149 | def test_noresult_noblock(self): | |
176 |
|
|
150 | d = defer.Deferred() | |
177 |
|
|
151 | did = self.pdm.save_pending_deferred(d) | |
178 | d.addCallback(lambda r: d2) |
|
152 | d2 = self.pdm.get_pending_deferred(did,False) | |
179 | did = self.pdm.save_pending_deferred(d) |
|
153 | d2.addErrback(lambda f: self.assertRaises(error.ResultNotCompleted, f.raiseException)) | |
180 | d.callback('foo') |
|
154 | ||
181 | d3 = self.pdm.get_pending_deferred(did,False) |
|
155 | def test_with_callbacks(self): | |
182 | d3.addErrback(lambda f: self.assertRaises(error.ResultNotCompleted, f.raiseException)) |
|
156 | d = defer.Deferred() | |
183 | d2.callback('bar') |
|
157 | d.addCallback(lambda r: r+' foo') | |
184 | d3 = self.pdm.get_pending_deferred(did,False) |
|
158 | d.addCallback(lambda r: r+' bar') | |
185 | d3.addCallback(lambda r: self.assertEquals(r,'bar')) |
|
159 | did = self.pdm.save_pending_deferred(d) | |
|
160 | d2 = self.pdm.get_pending_deferred(did,True) | |||
|
161 | d.callback('bam') | |||
|
162 | d2.addCallback(lambda r: self.assertEquals(r,'bam foo bar')) | |||
|
163 | ||||
|
164 | def test_with_errbacks(self): | |||
|
165 | class MyError(Exception): | |||
|
166 | pass | |||
|
167 | d = defer.Deferred() | |||
|
168 | d.addCallback(lambda r: 'foo') | |||
|
169 | d.addErrback(lambda f: 'caught error') | |||
|
170 | did = self.pdm.save_pending_deferred(d) | |||
|
171 | d2 = self.pdm.get_pending_deferred(did,True) | |||
|
172 | d.errback(failure.Failure(MyError('bam'))) | |||
|
173 | d2.addErrback(lambda f: self.assertRaises(MyError, f.raiseException)) | |||
|
174 | ||||
|
175 | def test_nested_deferreds(self): | |||
|
176 | d = defer.Deferred() | |||
|
177 | d2 = defer.Deferred() | |||
|
178 | d.addCallback(lambda r: d2) | |||
|
179 | did = self.pdm.save_pending_deferred(d) | |||
|
180 | d.callback('foo') | |||
|
181 | d3 = self.pdm.get_pending_deferred(did,False) | |||
|
182 | d3.addErrback(lambda f: self.assertRaises(error.ResultNotCompleted, f.raiseException)) | |||
|
183 | d2.callback('bar') | |||
|
184 | d3 = self.pdm.get_pending_deferred(did,False) | |||
|
185 | d3.addCallback(lambda r: self.assertEquals(r,'bar')) | |||
186 |
|
186 |
@@ -26,25 +26,26 b' try:' | |||||
26 | from IPython.testing.util import DeferredTestCase |
|
26 | from IPython.testing.util import DeferredTestCase | |
27 | from IPython.kernel.tests.tasktest import ITaskControllerTestCase |
|
27 | from IPython.kernel.tests.tasktest import ITaskControllerTestCase | |
28 | except ImportError: |
|
28 | except ImportError: | |
29 | pass |
|
29 | import nose | |
30 | else: |
|
30 | raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap") | |
31 | #------------------------------------------------------------------------------- |
|
|||
32 | # Tests |
|
|||
33 | #------------------------------------------------------------------------------- |
|
|||
34 |
|
31 | |||
35 | class BasicTaskControllerTestCase(DeferredTestCase, ITaskControllerTestCase): |
|
32 | #------------------------------------------------------------------------------- | |
|
33 | # Tests | |||
|
34 | #------------------------------------------------------------------------------- | |||
|
35 | ||||
|
36 | class BasicTaskControllerTestCase(DeferredTestCase, ITaskControllerTestCase): | |||
|
37 | ||||
|
38 | def setUp(self): | |||
|
39 | self.controller = cs.ControllerService() | |||
|
40 | self.controller.startService() | |||
|
41 | self.multiengine = IMultiEngine(self.controller) | |||
|
42 | self.tc = task.ITaskController(self.controller) | |||
|
43 | self.tc.failurePenalty = 0 | |||
|
44 | self.engines=[] | |||
36 |
|
45 | |||
37 |
|
|
46 | def tearDown(self): | |
38 |
|
|
47 | self.controller.stopService() | |
39 | self.controller.startService() |
|
48 | for e in self.engines: | |
40 | self.multiengine = IMultiEngine(self.controller) |
|
49 | e.stopService() | |
41 | self.tc = task.ITaskController(self.controller) |
|
|||
42 | self.tc.failurePenalty = 0 |
|
|||
43 | self.engines=[] |
|
|||
44 |
|
||||
45 | def tearDown(self): |
|
|||
46 | self.controller.stopService() |
|
|||
47 | for e in self.engines: |
|
|||
48 | e.stopService() |
|
|||
49 |
|
50 | |||
50 |
|
51 |
@@ -33,129 +33,130 b' try:' | |||||
33 | from IPython.kernel.error import CompositeError |
|
33 | from IPython.kernel.error import CompositeError | |
34 | from IPython.kernel.parallelfunction import ParallelFunction |
|
34 | from IPython.kernel.parallelfunction import ParallelFunction | |
35 | except ImportError: |
|
35 | except ImportError: | |
36 | pass |
|
36 | import nose | |
37 | else: |
|
37 | raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap") | |
38 |
|
38 | |||
39 | #------------------------------------------------------------------------------- |
|
|||
40 | # Tests |
|
|||
41 | #------------------------------------------------------------------------------- |
|
|||
42 |
|
39 | |||
43 | def _raise_it(f): |
|
40 | #------------------------------------------------------------------------------- | |
44 | try: |
|
41 | # Tests | |
45 | f.raiseException() |
|
42 | #------------------------------------------------------------------------------- | |
46 | except CompositeError, e: |
|
|||
47 | e.raise_exception() |
|
|||
48 |
|
43 | |||
49 | class TaskTest(DeferredTestCase, ITaskControllerTestCase): |
|
44 | def _raise_it(f): | |
|
45 | try: | |||
|
46 | f.raiseException() | |||
|
47 | except CompositeError, e: | |||
|
48 | e.raise_exception() | |||
50 |
|
49 | |||
51 | def setUp(self): |
|
50 | class TaskTest(DeferredTestCase, ITaskControllerTestCase): | |
52 |
|
51 | |||
53 | self.engines = [] |
|
52 | def setUp(self): | |
54 |
|
53 | |||
55 | self.controller = cs.ControllerService() |
|
54 | self.engines = [] | |
56 | self.controller.startService() |
|
55 | ||
57 | self.imultiengine = me.IMultiEngine(self.controller) |
|
56 | self.controller = cs.ControllerService() | |
58 | self.itc = taskmodule.ITaskController(self.controller) |
|
57 | self.controller.startService() | |
59 | self.itc.failurePenalty = 0 |
|
58 | self.imultiengine = me.IMultiEngine(self.controller) | |
60 |
|
59 | self.itc = taskmodule.ITaskController(self.controller) | ||
61 | self.mec_referenceable = IFCSynchronousMultiEngine(self.imultiengine) |
|
60 | self.itc.failurePenalty = 0 | |
62 | self.tc_referenceable = IFCTaskController(self.itc) |
|
61 | ||
63 |
|
62 | self.mec_referenceable = IFCSynchronousMultiEngine(self.imultiengine) | ||
64 | self.controller_tub = Tub() |
|
63 | self.tc_referenceable = IFCTaskController(self.itc) | |
65 | self.controller_tub.listenOn('tcp:10105:interface=127.0.0.1') |
|
64 | ||
66 | self.controller_tub.setLocation('127.0.0.1:10105') |
|
65 | self.controller_tub = Tub() | |
67 |
|
66 | self.controller_tub.listenOn('tcp:10105:interface=127.0.0.1') | ||
68 | mec_furl = self.controller_tub.registerReference(self.mec_referenceable) |
|
67 | self.controller_tub.setLocation('127.0.0.1:10105') | |
69 | tc_furl = self.controller_tub.registerReference(self.tc_referenceable) |
|
68 | ||
70 |
|
|
69 | mec_furl = self.controller_tub.registerReference(self.mec_referenceable) | |
71 |
|
70 | tc_furl = self.controller_tub.registerReference(self.tc_referenceable) | ||
72 | self.client_tub = ClientConnector() |
|
71 | self.controller_tub.startService() | |
73 | d = self.client_tub.get_multiengine_client(mec_furl) |
|
72 | ||
74 | d.addCallback(self.handle_mec_client) |
|
73 | self.client_tub = ClientConnector() | |
75 |
|
|
74 | d = self.client_tub.get_multiengine_client(mec_furl) | |
76 |
|
|
75 | d.addCallback(self.handle_mec_client) | |
77 | return d |
|
76 | d.addCallback(lambda _: self.client_tub.get_task_client(tc_furl)) | |
78 |
|
77 | d.addCallback(self.handle_tc_client) | ||
79 | def handle_mec_client(self, client): |
|
78 | return d | |
80 | self.multiengine = client |
|
79 | ||
|
80 | def handle_mec_client(self, client): | |||
|
81 | self.multiengine = client | |||
|
82 | ||||
|
83 | def handle_tc_client(self, client): | |||
|
84 | self.tc = client | |||
|
85 | ||||
|
86 | def tearDown(self): | |||
|
87 | dlist = [] | |||
|
88 | # Shut down the multiengine client | |||
|
89 | d = self.client_tub.tub.stopService() | |||
|
90 | dlist.append(d) | |||
|
91 | # Shut down the engines | |||
|
92 | for e in self.engines: | |||
|
93 | e.stopService() | |||
|
94 | # Shut down the controller | |||
|
95 | d = self.controller_tub.stopService() | |||
|
96 | d.addBoth(lambda _: self.controller.stopService()) | |||
|
97 | dlist.append(d) | |||
|
98 | return defer.DeferredList(dlist) | |||
|
99 | ||||
|
100 | def test_mapper(self): | |||
|
101 | self.addEngine(1) | |||
|
102 | m = self.tc.mapper() | |||
|
103 | self.assertEquals(m.task_controller,self.tc) | |||
|
104 | self.assertEquals(m.clear_before,False) | |||
|
105 | self.assertEquals(m.clear_after,False) | |||
|
106 | self.assertEquals(m.retries,0) | |||
|
107 | self.assertEquals(m.recovery_task,None) | |||
|
108 | self.assertEquals(m.depend,None) | |||
|
109 | self.assertEquals(m.block,True) | |||
|
110 | ||||
|
111 | def test_map_default(self): | |||
|
112 | self.addEngine(1) | |||
|
113 | m = self.tc.mapper() | |||
|
114 | d = m.map(lambda x: 2*x, range(10)) | |||
|
115 | d.addCallback(lambda r: self.assertEquals(r,[2*x for x in range(10)])) | |||
|
116 | d.addCallback(lambda _: self.tc.map(lambda x: 2*x, range(10))) | |||
|
117 | d.addCallback(lambda r: self.assertEquals(r,[2*x for x in range(10)])) | |||
|
118 | return d | |||
|
119 | ||||
|
120 | def test_map_noblock(self): | |||
|
121 | self.addEngine(1) | |||
|
122 | m = self.tc.mapper(block=False) | |||
|
123 | d = m.map(lambda x: 2*x, range(10)) | |||
|
124 | d.addCallback(lambda r: self.assertEquals(r,[x for x in range(10)])) | |||
|
125 | return d | |||
|
126 | ||||
|
127 | def test_mapper_fail(self): | |||
|
128 | self.addEngine(1) | |||
|
129 | m = self.tc.mapper() | |||
|
130 | d = m.map(lambda x: 1/0, range(10)) | |||
|
131 | d.addBoth(lambda f: self.assertRaises(ZeroDivisionError, _raise_it, f)) | |||
|
132 | return d | |||
|
133 | ||||
|
134 | def test_parallel(self): | |||
|
135 | self.addEngine(1) | |||
|
136 | p = self.tc.parallel() | |||
|
137 | self.assert_(isinstance(p, ParallelFunction)) | |||
|
138 | @p | |||
|
139 | def f(x): return 2*x | |||
|
140 | d = f(range(10)) | |||
|
141 | d.addCallback(lambda r: self.assertEquals(r,[2*x for x in range(10)])) | |||
|
142 | return d | |||
81 |
|
143 | |||
82 | def handle_tc_client(self, client): |
|
144 | def test_parallel_noblock(self): | |
83 | self.tc = client |
|
145 | self.addEngine(1) | |
|
146 | p = self.tc.parallel(block=False) | |||
|
147 | self.assert_(isinstance(p, ParallelFunction)) | |||
|
148 | @p | |||
|
149 | def f(x): return 2*x | |||
|
150 | d = f(range(10)) | |||
|
151 | d.addCallback(lambda r: self.assertEquals(r,[x for x in range(10)])) | |||
|
152 | return d | |||
84 |
|
153 | |||
85 |
|
|
154 | def test_parallel_fail(self): | |
86 | dlist = [] |
|
155 | self.addEngine(1) | |
87 | # Shut down the multiengine client |
|
156 | p = self.tc.parallel() | |
88 | d = self.client_tub.tub.stopService() |
|
157 | self.assert_(isinstance(p, ParallelFunction)) | |
89 | dlist.append(d) |
|
158 | @p | |
90 | # Shut down the engines |
|
159 | def f(x): return 1/0 | |
91 | for e in self.engines: |
|
160 | d = f(range(10)) | |
92 | e.stopService() |
|
161 | d.addBoth(lambda f: self.assertRaises(ZeroDivisionError, _raise_it, f)) | |
93 | # Shut down the controller |
|
162 | return d No newline at end of file | |
94 | d = self.controller_tub.stopService() |
|
|||
95 | d.addBoth(lambda _: self.controller.stopService()) |
|
|||
96 | dlist.append(d) |
|
|||
97 | return defer.DeferredList(dlist) |
|
|||
98 |
|
||||
99 | def test_mapper(self): |
|
|||
100 | self.addEngine(1) |
|
|||
101 | m = self.tc.mapper() |
|
|||
102 | self.assertEquals(m.task_controller,self.tc) |
|
|||
103 | self.assertEquals(m.clear_before,False) |
|
|||
104 | self.assertEquals(m.clear_after,False) |
|
|||
105 | self.assertEquals(m.retries,0) |
|
|||
106 | self.assertEquals(m.recovery_task,None) |
|
|||
107 | self.assertEquals(m.depend,None) |
|
|||
108 | self.assertEquals(m.block,True) |
|
|||
109 |
|
||||
110 | def test_map_default(self): |
|
|||
111 | self.addEngine(1) |
|
|||
112 | m = self.tc.mapper() |
|
|||
113 | d = m.map(lambda x: 2*x, range(10)) |
|
|||
114 | d.addCallback(lambda r: self.assertEquals(r,[2*x for x in range(10)])) |
|
|||
115 | d.addCallback(lambda _: self.tc.map(lambda x: 2*x, range(10))) |
|
|||
116 | d.addCallback(lambda r: self.assertEquals(r,[2*x for x in range(10)])) |
|
|||
117 | return d |
|
|||
118 |
|
||||
119 | def test_map_noblock(self): |
|
|||
120 | self.addEngine(1) |
|
|||
121 | m = self.tc.mapper(block=False) |
|
|||
122 | d = m.map(lambda x: 2*x, range(10)) |
|
|||
123 | d.addCallback(lambda r: self.assertEquals(r,[x for x in range(10)])) |
|
|||
124 | return d |
|
|||
125 |
|
||||
126 | def test_mapper_fail(self): |
|
|||
127 | self.addEngine(1) |
|
|||
128 | m = self.tc.mapper() |
|
|||
129 | d = m.map(lambda x: 1/0, range(10)) |
|
|||
130 | d.addBoth(lambda f: self.assertRaises(ZeroDivisionError, _raise_it, f)) |
|
|||
131 | return d |
|
|||
132 |
|
||||
133 | def test_parallel(self): |
|
|||
134 | self.addEngine(1) |
|
|||
135 | p = self.tc.parallel() |
|
|||
136 | self.assert_(isinstance(p, ParallelFunction)) |
|
|||
137 | @p |
|
|||
138 | def f(x): return 2*x |
|
|||
139 | d = f(range(10)) |
|
|||
140 | d.addCallback(lambda r: self.assertEquals(r,[2*x for x in range(10)])) |
|
|||
141 | return d |
|
|||
142 |
|
||||
143 | def test_parallel_noblock(self): |
|
|||
144 | self.addEngine(1) |
|
|||
145 | p = self.tc.parallel(block=False) |
|
|||
146 | self.assert_(isinstance(p, ParallelFunction)) |
|
|||
147 | @p |
|
|||
148 | def f(x): return 2*x |
|
|||
149 | d = f(range(10)) |
|
|||
150 | d.addCallback(lambda r: self.assertEquals(r,[x for x in range(10)])) |
|
|||
151 | return d |
|
|||
152 |
|
||||
153 | def test_parallel_fail(self): |
|
|||
154 | self.addEngine(1) |
|
|||
155 | p = self.tc.parallel() |
|
|||
156 | self.assert_(isinstance(p, ParallelFunction)) |
|
|||
157 | @p |
|
|||
158 | def f(x): return 1/0 |
|
|||
159 | d = f(range(10)) |
|
|||
160 | d.addBoth(lambda f: self.assertRaises(ZeroDivisionError, _raise_it, f)) |
|
|||
161 | return d No newline at end of file |
|
1 | NO CONTENT: modified file chmod 100755 => 100644 |
|
NO CONTENT: modified file chmod 100755 => 100644 |
@@ -93,28 +93,28 b' Specific subpackages' | |||||
93 | -------------------- |
|
93 | -------------------- | |
94 |
|
94 | |||
95 | ``core`` |
|
95 | ``core`` | |
96 |
|
|
96 | This is the core functionality of IPython that is independent of the | |
97 |
|
|
97 | terminal, network and GUIs. Most of the code that is in the current | |
98 |
|
|
98 | IPython trunk will be refactored, cleaned up and moved here. | |
99 |
|
99 | |||
100 | ``kernel`` |
|
100 | ``kernel`` | |
101 |
|
|
101 | The enables the IPython core to be expose to a the network. This is | |
102 |
|
|
102 | also where all of the parallel computing capabilities are to be found. | |
103 |
|
103 | |||
104 | ``config`` |
|
104 | ``config`` | |
105 |
|
|
105 | The configuration package used by IPython. | |
106 |
|
106 | |||
107 | ``frontends`` |
|
107 | ``frontends`` | |
108 |
|
|
108 | The various frontends for IPython. A frontend is the end-user application | |
109 |
|
|
109 | that exposes the capabilities of IPython to the user. The most basic frontend | |
110 |
|
|
110 | will simply be a terminal based application that looks just like today 's | |
111 |
|
|
111 | IPython. Other frontends will likely be more powerful and based on GUI toolkits. | |
112 |
|
112 | |||
113 | ``notebook`` |
|
113 | ``notebook`` | |
114 |
|
|
114 | An application that allows users to work with IPython notebooks. | |
115 |
|
115 | |||
116 | ``tools`` |
|
116 | ``tools`` | |
117 |
|
|
117 | This is where general utilities go. | |
118 |
|
118 | |||
119 |
|
119 | |||
120 | Version control |
|
120 | Version control | |
@@ -125,17 +125,17 b' to contribute code to IPython. Here is a sketch of how to use Bazaar for IPytho' | |||||
125 | development. First, you should install Bazaar. After you have done that, make |
|
125 | development. First, you should install Bazaar. After you have done that, make | |
126 | sure that it is working by getting the latest main branch of IPython:: |
|
126 | sure that it is working by getting the latest main branch of IPython:: | |
127 |
|
127 | |||
128 |
|
|
128 | $ bzr branch lp:ipython | |
129 |
|
129 | |||
130 | Now you can create a new branch for you to do your work in:: |
|
130 | Now you can create a new branch for you to do your work in:: | |
131 |
|
131 | |||
132 |
|
|
132 | $ bzr branch ipython ipython-mybranch | |
133 |
|
133 | |||
134 | The typical work cycle in this branch will be to make changes in `ipython-mybranch` |
|
134 | The typical work cycle in this branch will be to make changes in `ipython-mybranch` | |
135 | and then commit those changes using the commit command:: |
|
135 | and then commit those changes using the commit command:: | |
136 |
|
136 | |||
137 |
|
|
137 | $ ...do work in ipython-mybranch... | |
138 |
|
|
138 | $ bzr ci -m "the commit message goes here" | |
139 |
|
139 | |||
140 | Please note that since we now don't use an old-style linear ChangeLog |
|
140 | Please note that since we now don't use an old-style linear ChangeLog | |
141 | (that tends to cause problems with distributed version control |
|
141 | (that tends to cause problems with distributed version control | |
@@ -156,26 +156,26 b' the project, and the `--short` log option becomes a nice summary.' | |||||
156 | While working with this branch, it is a good idea to merge in changes that have been |
|
156 | While working with this branch, it is a good idea to merge in changes that have been | |
157 | made upstream in the parent branch. This can be done by doing:: |
|
157 | made upstream in the parent branch. This can be done by doing:: | |
158 |
|
158 | |||
159 |
|
|
159 | $ bzr pull | |
160 |
|
160 | |||
161 | If this command shows that the branches have diverged, then you should do a merge |
|
161 | If this command shows that the branches have diverged, then you should do a merge | |
162 | instead:: |
|
162 | instead:: | |
163 |
|
163 | |||
164 |
|
|
164 | $ bzr merge lp:ipython | |
165 |
|
165 | |||
166 | If you want others to be able to see your branch, you can create an account with |
|
166 | If you want others to be able to see your branch, you can create an account with | |
167 | launchpad and push the branch to your own workspace:: |
|
167 | launchpad and push the branch to your own workspace:: | |
168 |
|
168 | |||
169 |
|
|
169 | $ bzr push bzr+ssh://<me>@bazaar.launchpad.net/~<me>/+junk/ipython-mybranch | |
170 |
|
170 | |||
171 | Finally, once the work in your branch is done, you can merge your changes back into |
|
171 | Finally, once the work in your branch is done, you can merge your changes back into | |
172 | the `ipython` branch by using merge:: |
|
172 | the `ipython` branch by using merge:: | |
173 |
|
173 | |||
174 |
|
|
174 | $ cd ipython | |
175 |
|
|
175 | $ merge ../ipython-mybranch | |
176 |
|
|
176 | [resolve any conflicts] | |
177 |
|
|
177 | $ bzr ci -m "Fixing that bug" | |
178 |
|
|
178 | $ bzr push | |
179 |
|
179 | |||
180 | But this will require you to have write permissions to the `ipython` branch. It you don't |
|
180 | But this will require you to have write permissions to the `ipython` branch. It you don't | |
181 | you can tell one of the IPython devs about your branch and they can do the merge for you. |
|
181 | you can tell one of the IPython devs about your branch and they can do the merge for you. | |
@@ -349,6 +349,47 b' IPython. The current prototype of ``tconfig`` is located in the IPython sandbox.' | |||||
349 | .. _ConfigObj: http://www.voidspace.org.uk/python/configobj.html |
|
349 | .. _ConfigObj: http://www.voidspace.org.uk/python/configobj.html | |
350 | .. _Traits: http://code.enthought.com/traits/ |
|
350 | .. _Traits: http://code.enthought.com/traits/ | |
351 |
|
351 | |||
|
352 | Installation and testing scenarios | |||
|
353 | ================================== | |||
|
354 | ||||
|
355 | This section outlines the various scenarios that we need to test before we release an IPython version. These scenarios represent different ways of installing IPython and its dependencies. | |||
|
356 | ||||
|
357 | Installation scenarios | |||
|
358 | ---------------------- | |||
|
359 | ||||
|
360 | 1. Install from tarball using `python setup.py install`. | |||
|
361 | a. With only readline+nose dependencies installed (test1) | |||
|
362 | ||||
|
363 | virtualenv --no-site-packages test1 | |||
|
364 | # Activate it | |||
|
365 | easy_install nose | |||
|
366 | easy_install readline # On OS X or pyreadline on win32 | |||
|
367 | cd ipython-0.9.beta3 | |||
|
368 | python setup.py install | |||
|
369 | ||||
|
370 | b. With all dependencies installed (readline, zope.interface, | |||
|
371 | Twisted, foolscap, Sphinx, nose, pyOpenSSL) (test2) | |||
|
372 | 2. Install using easy_install. | |||
|
373 | a. With only readline+nose dependencies installed (test3) | |||
|
374 | i. Default dependencies. | |||
|
375 | ii. Optional dependency sets (kernel, doc, test, security) | |||
|
376 | easy_install -f ipython-0.9.beta3-py2.5.egg IPython[kernel,doc,test,security] | |||
|
377 | ||||
|
378 | b. With all dependencies already installed (test2) | |||
|
379 | ||||
|
380 | ||||
|
381 | Tests to run for these scenarios | |||
|
382 | -------------------------------- | |||
|
383 | ||||
|
384 | 1. Run the full test suite. | |||
|
385 | 2. Start a controller and engines and try a few things by hand. | |||
|
386 | a. Using ipcluster. | |||
|
387 | b. Using ipcontroller/ipengine by hand. | |||
|
388 | 3. Run a few of the parallel examples. | |||
|
389 | 4. Try the kernel with and without security with and without PyOpenSSL | |||
|
390 | installed. | |||
|
391 | 5. Beat on the IPython terminal a bunch. | |||
|
392 | 6. Make sure that furl files are being put in proper locations. | |||
352 |
|
393 | |||
353 |
|
394 | |||
354 |
|
395 |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now