Show More
@@ -6,7 +6,6 b'' | |||
|
6 | 6 | # Imports |
|
7 | 7 | #----------------------------------------------------------------------------- |
|
8 | 8 | |
|
9 | import nose.tools as nt | |
|
10 | 9 | from IPython.core.error import TryNext |
|
11 | 10 | from IPython.core.hooks import CommandChainDispatcher |
|
12 | 11 | |
@@ -38,27 +37,26 b' class Fail(object):' | |||
|
38 | 37 | |
|
39 | 38 | def test_command_chain_dispatcher_ff(): |
|
40 | 39 | """Test two failing hooks""" |
|
41 |
fail1 = Fail( |
|
|
42 |
fail2 = Fail( |
|
|
43 | dp = CommandChainDispatcher([(0, fail1), | |
|
44 | (10, fail2)]) | |
|
40 | fail1 = Fail("fail1") | |
|
41 | fail2 = Fail("fail2") | |
|
42 | dp = CommandChainDispatcher([(0, fail1), (10, fail2)]) | |
|
45 | 43 | |
|
46 | 44 | try: |
|
47 | 45 | dp() |
|
48 | 46 | except TryNext as e: |
|
49 |
|
|
|
47 | assert str(e) == "fail2" | |
|
50 | 48 | else: |
|
51 | 49 | assert False, "Expected exception was not raised." |
|
52 | 50 | |
|
53 |
|
|
|
54 |
|
|
|
51 | assert fail1.called is True | |
|
52 | assert fail2.called is True | |
|
55 | 53 | |
|
56 | 54 | def test_command_chain_dispatcher_fofo(): |
|
57 | 55 | """Test a mixture of failing and succeeding hooks.""" |
|
58 |
fail1 = Fail( |
|
|
59 |
fail2 = Fail( |
|
|
60 |
okay1 = Okay( |
|
|
61 |
okay2 = Okay( |
|
|
56 | fail1 = Fail("fail1") | |
|
57 | fail2 = Fail("fail2") | |
|
58 | okay1 = Okay("okay1") | |
|
59 | okay2 = Okay("okay2") | |
|
62 | 60 | |
|
63 | 61 | dp = CommandChainDispatcher([(0, fail1), |
|
64 | 62 | # (5, okay1), # add this later |
@@ -66,12 +64,12 b' def test_command_chain_dispatcher_fofo():' | |||
|
66 | 64 | (15, okay2)]) |
|
67 | 65 | dp.add(okay1, 5) |
|
68 | 66 | |
|
69 |
|
|
|
67 | assert dp() == "okay1" | |
|
70 | 68 | |
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
69 | assert fail1.called is True | |
|
70 | assert okay1.called is True | |
|
71 | assert fail2.called is False | |
|
72 | assert okay2.called is False | |
|
75 | 73 | |
|
76 | 74 | def test_command_chain_dispatcher_eq_priority(): |
|
77 | 75 | okay1 = Okay(u'okay1') |
General Comments 0
You need to be logged in to leave comments.
Login now