diff --git a/tests/_test_tokenizer.py b/tests/_test_tokenizer.py index bafb593..2571692 100644 --- a/tests/_test_tokenizer.py +++ b/tests/_test_tokenizer.py @@ -64,14 +64,15 @@ class TokenizerTestCase(object): raw = line[len("output:"):].strip() try: data["output"] = eval(raw, vars(tokens)) - except Exception: - raise _TestParseError() - except _TestParseError: + except Exception as err: + raise _TestParseError(err) + except _TestParseError as err: if data["name"]: - error = "Could not parse test '{0}' in '{1}'" - print(error.format(data["name"], filename)) + error = "Could not parse test '{0}' in '{1}':\n\t{2}" + print(error.format(data["name"], filename, err)) else: - print("Could not parse a test in '{0}'".format(filename)) + error = "Could not parse a test in '{0}':\n\t{1}" + print(error.format(filename, err)) continue if not data["name"]: error = "A test in '{0}' was ignored because it lacked a name" diff --git a/tests/tokenizer/templates.test b/tests/tokenizer/templates.test new file mode 100644 index 0000000..23ac38f --- /dev/null +++ b/tests/tokenizer/templates.test @@ -0,0 +1,32 @@ +name: no_params +label: simplest type of template +input: "{{template}}" +output: [TemplateOpen(), Text(text="template"), TemplateClose()] + +--- + +name: one_param_unnamed +label: basic template with one unnamed parameter +input: "{{foo|bar}}" +output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar"), TemplateClose()] + +--- + +name: one_param_named +label: basic template with one named parameter +input: "{{foo|bar=baz}}" +output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar"), TemplateParamEquals(), Text(text="baz"), TemplateClose()] + +--- + +name: multiple_unnamed_params +label: basic template with multiple unnamed parameters +input: "{{foo|bar|baz|biz|buzz}}" +output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar"), TemplateParamSeparator(), Text(text="baz"), TemplateParamSeparator(), Text(text="biz"), TemplateParamSeparator(), Text(text="buzz"), TemplateClose()] + +--- + +name: multiple_named_params +label: basic template with multiple named parameters +input: "{{foo|bar=baz|biz=buzz|buff=baff|usr=bin}}" +output: [TemplateOpen(), Text(text="foo"), TemplateParamSeparator(), Text(text="bar"), TemplateParamEquals(), Text(text="baz"), TemplateParamSeparator(), Text(text="biz"), TemplateParamEquals(), Text(text="buzz"), TemplateParamSeparator(), Text(text="buff"), TemplateParamEquals(), Text(text="baff"), TemplateParamSeparator(), Text(text="usr"), TemplateParamEquals(), Text(text="bin"), TemplateClose()]