Show More
@@ -91,39 +91,39 b' class ExecuteReply(object):' | |||
|
91 | 91 | |
|
92 | 92 | def __repr__(self): |
|
93 | 93 | pyout = self.metadata['pyout'] or {} |
|
94 | text_out = pyout.get('text/plain', '') | |
|
94 | text_out = pyout.get('data', {}).get('text/plain', '') | |
|
95 | 95 | if len(text_out) > 32: |
|
96 | 96 | text_out = text_out[:29] + '...' |
|
97 | 97 | |
|
98 | 98 | return "<ExecuteReply[%i]: %s>" % (self.execution_count, text_out) |
|
99 | 99 | |
|
100 | 100 | def _repr_html_(self): |
|
101 | pyout = self.metadata['pyout'] or {} | |
|
102 | return pyout.get("text/html") | |
|
101 | pyout = self.metadata['pyout'] or {'data':{}} | |
|
102 | return pyout['data'].get("text/html") | |
|
103 | 103 | |
|
104 | 104 | def _repr_latex_(self): |
|
105 | pyout = self.metadata['pyout'] or {} | |
|
106 | return pyout.get("text/latex") | |
|
105 | pyout = self.metadata['pyout'] or {'data':{}} | |
|
106 | return pyout['data'].get("text/latex") | |
|
107 | 107 | |
|
108 | 108 | def _repr_json_(self): |
|
109 | pyout = self.metadata['pyout'] or {} | |
|
110 | return pyout.get("application/json") | |
|
109 | pyout = self.metadata['pyout'] or {'data':{}} | |
|
110 | return pyout['data'].get("application/json") | |
|
111 | 111 | |
|
112 | 112 | def _repr_javascript_(self): |
|
113 | pyout = self.metadata['pyout'] or {} | |
|
114 | return pyout.get("application/javascript") | |
|
113 | pyout = self.metadata['pyout'] or {'data':{}} | |
|
114 | return pyout['data'].get("application/javascript") | |
|
115 | 115 | |
|
116 | 116 | def _repr_png_(self): |
|
117 | pyout = self.metadata['pyout'] or {} | |
|
118 | return pyout.get("image/png") | |
|
117 | pyout = self.metadata['pyout'] or {'data':{}} | |
|
118 | return pyout['data'].get("image/png") | |
|
119 | 119 | |
|
120 | 120 | def _repr_jpeg_(self): |
|
121 | pyout = self.metadata['pyout'] or {} | |
|
122 | return pyout.get("image/jpeg") | |
|
121 | pyout = self.metadata['pyout'] or {'data':{}} | |
|
122 | return pyout['data'].get("image/jpeg") | |
|
123 | 123 | |
|
124 | 124 | def _repr_svg_(self): |
|
125 | pyout = self.metadata['pyout'] or {} | |
|
126 | return pyout.get("image/svg+xml") | |
|
125 | pyout = self.metadata['pyout'] or {'data':{}} | |
|
126 | return pyout['data'].get("image/svg+xml") | |
|
127 | 127 | |
|
128 | 128 | |
|
129 | 129 | class Metadata(dict): |
@@ -834,9 +834,9 b' class Client(HasTraits):' | |||
|
834 | 834 | elif msg_type == 'pyin': |
|
835 | 835 | md.update({'pyin' : content['code']}) |
|
836 | 836 | elif msg_type == 'display_data': |
|
837 |
md['outputs'].append(content |
|
|
837 | md['outputs'].append(content) | |
|
838 | 838 | elif msg_type == 'pyout': |
|
839 |
md['pyout'] = content |
|
|
839 | md['pyout'] = content | |
|
840 | 840 | else: |
|
841 | 841 | # unhandled msg_type (status, etc.) |
|
842 | 842 | pass |
@@ -593,7 +593,7 b' class TestView(ClusterTestCase, ParametricTestCase):' | |||
|
593 | 593 | er = ar.get() |
|
594 | 594 | self._wait_for(lambda : bool(er.pyout)) |
|
595 | 595 | self.assertEquals(str(er), "<ExecuteReply[%i]: 5>" % er.execution_count) |
|
596 | self.assertEquals(er.pyout['text/plain'], '5') | |
|
596 | self.assertEquals(er.pyout['data']['text/plain'], '5') | |
|
597 | 597 | |
|
598 | 598 | def test_execute_reply_stdout(self): |
|
599 | 599 | e0 = self.client[self.client.ids[0]] |
@@ -610,7 +610,8 b' class TestView(ClusterTestCase, ParametricTestCase):' | |||
|
610 | 610 | self._wait_for(lambda : all(ar.pyout)) |
|
611 | 611 | |
|
612 | 612 | expected = [{'text/plain' : '5'}] * len(view) |
|
613 | self.assertEquals(ar.pyout, expected) | |
|
613 | mimes = [ out['data'] for out in ar.pyout ] | |
|
614 | self.assertEquals(mimes, expected) | |
|
614 | 615 | |
|
615 | 616 | def test_execute_silent(self): |
|
616 | 617 | """execute does not trigger pyout with silent=True""" |
@@ -645,9 +646,10 b' class TestView(ClusterTestCase, ParametricTestCase):' | |||
|
645 | 646 | ar = view.execute("[ display(i) for i in range(5) ]", block=True) |
|
646 | 647 | |
|
647 | 648 | self._wait_for(lambda : all(len(er.outputs) >= 5 for er in ar)) |
|
648 |
|
|
|
649 | expected = [outs] * len(view) | |
|
650 | self.assertEquals(ar.outputs, expected) | |
|
649 | expected = [ {u'text/plain' : unicode(j)} for j in range(5) ] | |
|
650 | for outputs in ar.outputs: | |
|
651 | mimes = [ out['data'] for out in outputs ] | |
|
652 | self.assertEquals(mimes, expected) | |
|
651 | 653 | |
|
652 | 654 | def test_apply_displaypub(self): |
|
653 | 655 | """apply tracks display_pub output""" |
@@ -661,9 +663,10 b' class TestView(ClusterTestCase, ParametricTestCase):' | |||
|
661 | 663 | ar = view.apply_async(publish) |
|
662 | 664 | ar.get(5) |
|
663 | 665 | self._wait_for(lambda : all(len(out) >= 5 for out in ar.outputs)) |
|
664 |
|
|
|
665 | expected = [outs] * len(view) | |
|
666 | self.assertEquals(ar.outputs, expected) | |
|
666 | expected = [ {u'text/plain' : unicode(j)} for j in range(5) ] | |
|
667 | for outputs in ar.outputs: | |
|
668 | mimes = [ out['data'] for out in outputs ] | |
|
669 | self.assertEquals(mimes, expected) | |
|
667 | 670 | |
|
668 | 671 | def test_execute_raises(self): |
|
669 | 672 | """exceptions in execute requests raise appropriately""" |
@@ -672,7 +675,7 b' class TestView(ClusterTestCase, ParametricTestCase):' | |||
|
672 | 675 | self.assertRaisesRemote(ZeroDivisionError, ar.get, 2) |
|
673 | 676 | |
|
674 | 677 | @dec.skipif_not_matplotlib |
|
675 |
def test_ |
|
|
678 | def test_magic_pylab(self): | |
|
676 | 679 | """%pylab works on engines""" |
|
677 | 680 | view = self.client[-1] |
|
678 | 681 | ar = view.execute("%pylab inline") |
@@ -684,6 +687,8 b' class TestView(ClusterTestCase, ParametricTestCase):' | |||
|
684 | 687 | self._wait_for(lambda : all(ar.outputs)) |
|
685 | 688 | self.assertEquals(len(reply.outputs), 1) |
|
686 | 689 | output = reply.outputs[0] |
|
687 |
self.assertTrue(" |
|
|
690 | self.assertTrue("data" in output) | |
|
691 | data = output['data'] | |
|
692 | self.assertTrue("image/png" in data) | |
|
688 | 693 | |
|
689 | 694 |
General Comments 0
You need to be logged in to leave comments.
Login now