Show More
@@ -50,7 +50,7 b' def flush_channels():' | |||||
50 | except Empty: |
|
50 | except Empty: | |
51 | break |
|
51 | break | |
52 | else: |
|
52 | else: | |
53 | validate_message(msg) |
|
53 | list(validate_message(msg)) | |
54 |
|
54 | |||
55 |
|
55 | |||
56 | def execute(code='', **kwargs): |
|
56 | def execute(code='', **kwargs): | |
@@ -60,14 +60,14 b" def execute(code='', **kwargs):" | |||||
60 |
|
60 | |||
61 | msg_id = shell.execute(code=code, **kwargs) |
|
61 | msg_id = shell.execute(code=code, **kwargs) | |
62 | reply = shell.get_msg(timeout=2) |
|
62 | reply = shell.get_msg(timeout=2) | |
63 | validate_message(reply, 'execute_reply', msg_id) |
|
63 | list(validate_message(reply, 'execute_reply', msg_id)) | |
64 | busy = sub.get_msg(timeout=2) |
|
64 | busy = sub.get_msg(timeout=2) | |
65 | validate_message(busy, 'status', msg_id) |
|
65 | list(validate_message(busy, 'status', msg_id)) | |
66 | nt.assert_equals(busy['content']['execution_state'], 'busy') |
|
66 | nt.assert_equals(busy['content']['execution_state'], 'busy') | |
67 |
|
67 | |||
68 | if not kwargs.get('silent'): |
|
68 | if not kwargs.get('silent'): | |
69 | pyin = sub.get_msg(timeout=2) |
|
69 | pyin = sub.get_msg(timeout=2) | |
70 | validate_message(pyin, 'pyin', msg_id) |
|
70 | list(validate_message(pyin, 'pyin', msg_id)) | |
71 | nt.assert_equals(pyin['content']['code'], code) |
|
71 | nt.assert_equals(pyin['content']['code'], code) | |
72 |
|
72 | |||
73 | return msg_id, reply['content'] |
|
73 | return msg_id, reply['content'] | |
@@ -220,7 +220,14 b' references = {' | |||||
220 |
|
220 | |||
221 |
|
221 | |||
222 | def validate_message(msg, msg_type=None, parent=None): |
|
222 | def validate_message(msg, msg_type=None, parent=None): | |
223 |
"""validate a message |
|
223 | """validate a message | |
|
224 | ||||
|
225 | This is a generator, and must be iterated through to actually | |||
|
226 | trigger each test. | |||
|
227 | ||||
|
228 | If msg_type and/or parent are given, the msg_type and/or parent msg_id | |||
|
229 | are compared with the given values. | |||
|
230 | """ | |||
224 | RMessage().check(msg) |
|
231 | RMessage().check(msg) | |
225 | if msg_type: |
|
232 | if msg_type: | |
226 | yield nt.assert_equals(msg['msg_type'], msg_type) |
|
233 | yield nt.assert_equals(msg['msg_type'], msg_type) |
General Comments 0
You need to be logged in to leave comments.
Login now