Use first the dotted name variable in the PYSON context
issue11109 review383991002
This commit is contained in:
1 parent
51a08fb809
commit
1f42642bc3
2 files changed
+14
-1
No files matched your search
+1
-1
@@ -154,7 +154,7 @@ class Eval(PYSON):
|
||||
|
||||
@staticmethod
|
||||
def eval(dct, context):
|
||||
if '.' in dct['v']:
|
||||
if '.' in dct['v'] and dct['v'] not in context:
|
||||
base, name = dct['v'].split('.', 1)
|
||||
return Eval.eval({
|
||||
'v': name,
|
||||
|
||||
@@ -846,6 +846,19 @@ class PYSONTestCase(unittest.TestCase):
|
||||
]:
|
||||
self.assertEqual(pyson.PYSONDecoder(ctx).decode(eval), result)
|
||||
|
||||
def test_Eval_dot_notation_in_context(self):
|
||||
"Test pyson.Eval with dot notation in context"
|
||||
|
||||
eval = pyson.PYSONEncoder().encode(pyson.Eval('foo.bar', 0))
|
||||
ctx = {
|
||||
'foo.bar': 1,
|
||||
'foo': {
|
||||
'bar': 0,
|
||||
},
|
||||
}
|
||||
|
||||
self.assertEqual(pyson.PYSONDecoder(ctx).decode(eval), 1)
|
||||
|
||||
def test_eval_true(self):
|
||||
"Test PYSON.eval JS true"
|
||||
self.assertEqual(eval('true', pyson.CONTEXT), True)
|
||||
|
||||
Reference in new issue
Block a user