##// END OF EJS Templates
test namedtuple as return and apply arg
MinRK -
Show More
@@ -19,6 +19,7 b' Authors:'
19 19 import sys
20 20 import platform
21 21 import time
22 from collections import namedtuple
22 23 from tempfile import mktemp
23 24 from StringIO import StringIO
24 25
@@ -43,6 +44,8 b' from .clienttest import ClusterTestCase, crash, wait, skip_without'
43 44 def setup():
44 45 add_engines(3, total=True)
45 46
47 point = namedtuple("point", "x y")
48
46 49 class TestView(ClusterTestCase, ParametricTestCase):
47 50
48 51 def setUp(self):
@@ -735,3 +738,22 b' class TestView(ClusterTestCase, ParametricTestCase):'
735 738 r = view.apply_sync(lambda x: x.b, ra)
736 739 self.assertEqual(r, 0)
737 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