0001-misc-validate-is-varname-.-syntax-13185.patch
tests/test_ezt.py | ||
---|---|---|
3 | 3 |
from StringIO import StringIO |
4 | 4 | |
5 | 5 |
from quixote import cleanup |
6 |
from wcs.qommon.ezt import Template, UnclosedBlocksError, UnmatchedEndError, UnmatchedElseError |
|
6 |
from wcs.qommon.ezt import (Template, UnclosedBlocksError, UnmatchedEndError, |
|
7 |
UnmatchedElseError, ArgCountSyntaxError) |
|
7 | 8 |
from wcs.scripts import ScriptsSubstitutionProxy |
8 | 9 | |
9 | 10 |
from utilities import get_app, create_temporary_pub |
... | ... | |
109 | 110 |
except UnmatchedElseError as e: |
110 | 111 |
assert e.column == 3 and e.line == 0 |
111 | 112 | |
113 |
def test_missing_is_arg(): |
|
114 |
template = Template() |
|
115 |
with pytest.raises(ArgCountSyntaxError): |
|
116 |
template.parse('[is foobar][end]') |
|
117 |
try: |
|
118 |
template.parse('\ntest [is foobar][end]') |
|
119 |
except ArgCountSyntaxError as e: |
|
120 |
assert e.column == 5 and e.line == 1 |
|
121 | ||
112 | 122 |
def test_array_index(): |
113 | 123 |
template = Template() |
114 | 124 |
template.parse('<p>[foo.0]</p>') |
wcs/qommon/ezt.py | ||
---|---|---|
409 | 409 | |
410 | 410 |
# handle arg2 for the 'is' command |
411 | 411 |
if cmd == 'is': |
412 |
if len(args) != 3: |
|
413 |
raise ArgCountSyntaxError(str(args[1:]), line, column) |
|
412 | 414 |
args[2] = _prepare_ref(args[2], for_names, file_args) |
413 | 415 |
elif cmd == 'for': |
414 | 416 |
for_names.append(args[1][0]) # append the refname |
415 |
- |