0001-utils-mention-expression-on-condition-validation-err.patch
src/authentic2/utils/evaluate.py | ||
---|---|---|
91 | 91 |
else: |
92 | 92 |
ok = True |
93 | 93 |
if not ok: |
94 |
raise ExpressionError(_('expression is forbidden'), node=node, code='forbidden-expression') |
|
94 |
raise ExpressionError(_('expression "%(expression)s" is forbidden'), node=node, code='forbidden-expression')
|
|
95 | 95 | |
96 | 96 |
# specific node class check |
97 | 97 |
node_name = node.__class__.__name__ |
... | ... | |
123 | 123 |
except ExpressionError as e: |
124 | 124 |
if e.text is None: |
125 | 125 |
e.text = expression |
126 |
e.params = {'expression': expression} |
|
126 | 127 |
six.reraise(*sys.exc_info()) |
127 | 128 |
return compile(tree, expression, mode='eval') |
128 | 129 |
tests/test_utils_evaluate.py | ||
---|---|---|
53 | 53 | |
54 | 54 |
with pytest.raises(ExpressionError) as raised: |
55 | 55 |
v('a + b') |
56 |
assert str(raised.value) == '[\'expression "a + b" is forbidden\']' |
|
56 | 57 | |
57 | 58 |
with pytest.raises(ExpressionError) as raised: |
58 | 59 |
v('1 + 2') |
59 |
- |