Show More
@@ -128,13 +128,20 b' class View(HasTraits):' | |||||
128 |
|
128 | |||
129 | assert not self.__class__ is View, "Don't use base View objects, use subclasses" |
|
129 | assert not self.__class__ is View, "Don't use base View objects, use subclasses" | |
130 |
|
130 | |||
131 |
|
||||
132 | def __repr__(self): |
|
131 | def __repr__(self): | |
133 | strtargets = str(self.targets) |
|
132 | strtargets = str(self.targets) | |
134 | if len(strtargets) > 16: |
|
133 | if len(strtargets) > 16: | |
135 | strtargets = strtargets[:12]+'...]' |
|
134 | strtargets = strtargets[:12]+'...]' | |
136 | return "<%s %s>"%(self.__class__.__name__, strtargets) |
|
135 | return "<%s %s>"%(self.__class__.__name__, strtargets) | |
137 |
|
136 | |||
|
137 | def __len__(self): | |||
|
138 | if isinstance(self.targets, list): | |||
|
139 | return len(self.targets) | |||
|
140 | elif isinstance(self.targets, int): | |||
|
141 | return 1 | |||
|
142 | else: | |||
|
143 | return len(self.client) | |||
|
144 | ||||
138 | def set_flags(self, **kwargs): |
|
145 | def set_flags(self, **kwargs): | |
139 | """set my attribute flags by keyword. |
|
146 | """set my attribute flags by keyword. | |
140 |
|
147 |
@@ -25,6 +25,7 b' import zmq' | |||||
25 | from nose import SkipTest |
|
25 | from nose import SkipTest | |
26 |
|
26 | |||
27 | from IPython.testing import decorators as dec |
|
27 | from IPython.testing import decorators as dec | |
|
28 | from IPython.testing.ipunittest import ParametricTestCase | |||
28 |
|
29 | |||
29 | from IPython import parallel as pmod |
|
30 | from IPython import parallel as pmod | |
30 | from IPython.parallel import error |
|
31 | from IPython.parallel import error | |
@@ -39,7 +40,7 b' from .clienttest import ClusterTestCase, crash, wait, skip_without' | |||||
39 | def setup(): |
|
40 | def setup(): | |
40 | add_engines(3, total=True) |
|
41 | add_engines(3, total=True) | |
41 |
|
42 | |||
42 | class TestView(ClusterTestCase): |
|
43 | class TestView(ClusterTestCase, ParametricTestCase): | |
43 |
|
44 | |||
44 | def test_z_crash_mux(self): |
|
45 | def test_z_crash_mux(self): | |
45 | """test graceful handling of engine death (direct)""" |
|
46 | """test graceful handling of engine death (direct)""" | |
@@ -550,4 +551,21 b' class TestView(ClusterTestCase):' | |||||
550 | check = [ -1*i for i in r ] |
|
551 | check = [ -1*i for i in r ] | |
551 | result = e0.map_sync(lambda x: -1*x, r) |
|
552 | result = e0.map_sync(lambda x: -1*x, r) | |
552 | self.assertEquals(result, check) |
|
553 | self.assertEquals(result, check) | |
|
554 | ||||
|
555 | def test_len(self): | |||
|
556 | """len(view) makes sense""" | |||
|
557 | e0 = self.client[self.client.ids[0]] | |||
|
558 | yield self.assertEquals(len(e0), 1) | |||
|
559 | v = self.client[:] | |||
|
560 | yield self.assertEquals(len(v), len(self.client.ids)) | |||
|
561 | v = self.client.direct_view('all') | |||
|
562 | yield self.assertEquals(len(v), len(self.client.ids)) | |||
|
563 | v = self.client[:2] | |||
|
564 | yield self.assertEquals(len(v), 2) | |||
|
565 | v = self.client[:1] | |||
|
566 | yield self.assertEquals(len(v), 1) | |||
|
567 | v = self.client.load_balanced_view() | |||
|
568 | yield self.assertEquals(len(v), len(self.client.ids)) | |||
|
569 | # parametric tests seem to require manual closing? | |||
|
570 | self.client.close() | |||
553 |
|
571 |
General Comments 0
You need to be logged in to leave comments.
Login now