Show More
@@ -491,3 +491,17 b' class TestView(ClusterTestCase):' | |||||
491 | expected = [ 5*id for id in self.client.ids ] |
|
491 | expected = [ 5*id for id in self.client.ids ] | |
492 | self.assertEquals(result, expected) |
|
492 | self.assertEquals(result, expected) | |
493 |
|
493 | |||
|
494 | def test_eval_reference(self): | |||
|
495 | v = self.client[self.client.ids[0]] | |||
|
496 | v['g'] = range(5) | |||
|
497 | rg = pmod.Reference('g[0]') | |||
|
498 | echo = lambda x:x | |||
|
499 | self.assertEquals(v.apply_sync(echo, rg), 0) | |||
|
500 | ||||
|
501 | def test_reference_nameerror(self): | |||
|
502 | v = self.client[self.client.ids[0]] | |||
|
503 | r = pmod.Reference('elvis_has_left') | |||
|
504 | echo = lambda x:x | |||
|
505 | self.assertRaisesRemote(NameError, v.apply_sync, echo, r) | |||
|
506 | ||||
|
507 |
@@ -54,10 +54,8 b' class Reference(CannedObject):' | |||||
54 | def getObject(self, g=None): |
|
54 | def getObject(self, g=None): | |
55 | if g is None: |
|
55 | if g is None: | |
56 | g = globals() |
|
56 | g = globals() | |
57 |
|
|
57 | ||
58 |
|
|
58 | return eval(self.name, g) | |
59 | except KeyError: |
|
|||
60 | raise NameError("name %r is not defined"%self.name) |
|
|||
61 |
|
59 | |||
62 |
|
60 | |||
63 | class CannedFunction(CannedObject): |
|
61 | class CannedFunction(CannedObject): |
General Comments 0
You need to be logged in to leave comments.
Login now