##// END OF EJS Templates
Merge pull request #2327 from bfroehle/remote_push_pull_nested...
Min RK -
r8363:0af1e9d0 merge
parent child Browse files
Show More
@@ -700,4 +700,22 b' class TestView(ClusterTestCase, ParametricTestCase):'
700 700 drank = amr.get(5)
701 701 self.assertEqual(drank, [ r*2 for r in ranks ])
702 702
703 def test_nested_getitem_setitem(self):
704 """get and set with view['a.b']"""
705 view = self.client[-1]
706 view.execute('\n'.join([
707 'class A(object): pass',
708 'a = A()',
709 'a.b = 128',
710 ]), block=True)
711 ra = pmod.Reference('a')
712
713 r = view.apply_sync(lambda x: x.b, ra)
714 self.assertEqual(r, 128)
715 self.assertEqual(view['a.b'], 128)
716
717 view['a.b'] = 0
703 718
719 r = view.apply_sync(lambda x: x.b, ra)
720 self.assertEqual(r, 0)
721 self.assertEqual(view['a.b'], 0)
@@ -229,21 +229,24 b' def interactive(f):'
229 229 @interactive
230 230 def _push(**ns):
231 231 """helper method for implementing `client.push` via `client.apply`"""
232 globals().update(ns)
232 user_ns = globals()
233 tmp = '_IP_PUSH_TMP_'
234 while tmp in user_ns:
235 tmp = tmp + '_'
236 try:
237 for name, value in ns.iteritems():
238 user_ns[tmp] = value
239 exec "%s = %s" % (name, tmp) in user_ns
240 finally:
241 user_ns.pop(tmp, None)
233 242
234 243 @interactive
235 244 def _pull(keys):
236 245 """helper method for implementing `client.pull` via `client.apply`"""
237 user_ns = globals()
238 246 if isinstance(keys, (list,tuple, set)):
239 for key in keys:
240 if key not in user_ns:
241 raise NameError("name '%s' is not defined"%key)
242 return map(user_ns.get, keys)
247 return map(lambda key: eval(key, globals()), keys)
243 248 else:
244 if keys not in user_ns:
245 raise NameError("name '%s' is not defined"%keys)
246 return user_ns.get(keys)
249 return eval(keys, globals())
247 250
248 251 @interactive
249 252 def _execute(code):
General Comments 0
You need to be logged in to leave comments. Login now