Show More
@@ -19,6 +19,7 b' Authors:' | |||||
19 | import sys |
|
19 | import sys | |
20 | import platform |
|
20 | import platform | |
21 | import time |
|
21 | import time | |
|
22 | from collections import namedtuple | |||
22 | from tempfile import mktemp |
|
23 | from tempfile import mktemp | |
23 | from StringIO import StringIO |
|
24 | from StringIO import StringIO | |
24 |
|
25 | |||
@@ -43,6 +44,8 b' from .clienttest import ClusterTestCase, crash, wait, skip_without' | |||||
43 | def setup(): |
|
44 | def setup(): | |
44 | add_engines(3, total=True) |
|
45 | add_engines(3, total=True) | |
45 |
|
46 | |||
|
47 | point = namedtuple("point", "x y") | |||
|
48 | ||||
46 | class TestView(ClusterTestCase, ParametricTestCase): |
|
49 | class TestView(ClusterTestCase, ParametricTestCase): | |
47 |
|
50 | |||
48 | def setUp(self): |
|
51 | def setUp(self): | |
@@ -735,3 +738,22 b' class TestView(ClusterTestCase, ParametricTestCase):' | |||||
735 | r = view.apply_sync(lambda x: x.b, ra) |
|
738 | r = view.apply_sync(lambda x: x.b, ra) | |
736 | self.assertEqual(r, 0) |
|
739 | self.assertEqual(r, 0) | |
737 | self.assertEqual(view['a.b'], 0) |
|
740 | self.assertEqual(view['a.b'], 0) | |
|
741 | ||||
|
742 | def test_return_namedtuple(self): | |||
|
743 | def namedtuplify(x, y): | |||
|
744 | from IPython.parallel.tests.test_view import point | |||
|
745 | return point(x, y) | |||
|
746 | ||||
|
747 | view = self.client[-1] | |||
|
748 | p = view.apply_sync(namedtuplify, 1, 2) | |||
|
749 | self.assertEqual(p.x, 1) | |||
|
750 | self.assertEqual(p.y, 2) | |||
|
751 | ||||
|
752 | def test_apply_namedtuple(self): | |||
|
753 | def echoxy(p): | |||
|
754 | return p.y, p.x | |||
|
755 | ||||
|
756 | view = self.client[-1] | |||
|
757 | tup = view.apply_sync(echoxy, point(1, 2)) | |||
|
758 | self.assertEqual(tup, (2,1)) | |||
|
759 |
General Comments 0
You need to be logged in to leave comments.
Login now