Add arguments validation to parse_tr
This commit is contained in:
1
app/tests/unit/bad_args.fr.tr
Normal file
1
app/tests/unit/bad_args.fr.tr
Normal file
@@ -0,0 +1 @@
|
||||
Some @1 args @5=Some @1 args @5
|
||||
@@ -59,3 +59,23 @@ def test_parses_tr_error_on_bad_escape():
|
||||
parse_tr(filepath)
|
||||
|
||||
assert str(e.value) == "Line 1: Unknown escape character: x"
|
||||
|
||||
|
||||
def test_parses_tr_error_on_bad_args():
|
||||
dirname = os.path.dirname(__file__)
|
||||
filepath = os.path.join(dirname, "bad_args.fr.tr")
|
||||
|
||||
with pytest.raises(SyntaxError) as e:
|
||||
parse_tr(filepath)
|
||||
|
||||
assert "Line 1: Arguments out of order in source, found @5 and expected @2." in str(e.value)
|
||||
|
||||
|
||||
def test_parses_tr_error_on_unknown_arg():
|
||||
dirname = os.path.dirname(__file__)
|
||||
filepath = os.path.join(dirname, "unknown_arg.fr.tr")
|
||||
|
||||
with pytest.raises(SyntaxError) as e:
|
||||
parse_tr(filepath)
|
||||
|
||||
assert str(e.value) == "Line 1: Unknown argument @2 in translated string"
|
||||
|
||||
1
app/tests/unit/unknown_arg.fr.tr
Normal file
1
app/tests/unit/unknown_arg.fr.tr
Normal file
@@ -0,0 +1 @@
|
||||
Some @1 arg=Some @2 arg
|
||||
Reference in New Issue
Block a user