##// END OF EJS Templates
fix small client bugs + tests
MinRK -
Show More
@@ -378,7 +378,8 b' class Client(HasTraits):'
378 378 def ids(self):
379 379 """Always up-to-date ids property."""
380 380 self._flush_notifications()
381 return self._ids
381 # always copy:
382 return list(self._ids)
382 383
383 384 def close(self):
384 385 if self._closed:
@@ -878,8 +879,10 b' class Client(HasTraits):'
878 879 default: self.block
879 880
880 881 """
881 with open(filename, 'rb') as f:
882 code = f.read()
882 with open(filename, 'r') as f:
883 # add newline in case of trailing indented whitespace
884 # which will cause SyntaxError
885 code = f.read()+'\n'
883 886 return self.execute(code, targets=targets, block=block)
884 887
885 888 def _maybe_raise(self, result):
@@ -1,4 +1,5 b''
1 1 import time
2 from tempfile import mktemp
2 3
3 4 import nose.tools as nt
4 5
@@ -162,4 +163,25 b' class TestClient(ClusterTestCase):'
162 163 self.assertEquals(ahr.get(), ar.get())
163 164 ar2 = self.client.get_result(ar.msg_ids)
164 165 self.assertFalse(isinstance(ar2, AsyncHubResult))
166
167 def test_ids_list(self):
168 """test client.ids"""
169 self.add_engines(2)
170 ids = self.client.ids
171 self.assertEquals(ids, self.client._ids)
172 self.assertFalse(ids is self.client._ids)
173 ids.remove(ids[-1])
174 self.assertNotEquals(ids, self.client._ids)
175
176 def test_arun_newline(self):
177 """test that run appends newline to files"""
178 tmpfile = mktemp()
179 with open(tmpfile, 'w') as f:
180 f.write("""def g():
181 return 5
182 """)
183 v = self.client[-1]
184 v.run(tmpfile, block=True)
185 self.assertEquals(v.apply_sync_bound(lambda : g()), 5)
186
165 187 No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now