diff options
| author | Mistivia <i@mistivia.com> | 2025-01-15 19:12:12 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-01-15 19:12:46 +0800 |
| commit | 4da382953c830a61ae24ccbe95c4241db8788269 (patch) | |
| tree | 31f6d184273274e2660516d1ac1146b5661f20b6 /lib/crow/tests/template/test.py | |
restore
Diffstat (limited to 'lib/crow/tests/template/test.py')
| -rw-r--r-- | lib/crow/tests/template/test.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/crow/tests/template/test.py b/lib/crow/tests/template/test.py new file mode 100644 index 0000000..57bcaf8 --- /dev/null +++ b/lib/crow/tests/template/test.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +from __future__ import print_function +import glob +import json +import os +import subprocess +for testfile in glob.glob("*.json"): + testdoc = json.load(open(testfile)) + for test in testdoc["tests"]: + if "lambda" in test["data"]: + continue + open('data', 'w').write(json.dumps(test["data"])) + open('template', 'w').write(test["template"]) + if "partials" in test: + open('partials', 'w').write(json.dumps(test["partials"])) + else: + open('partials', 'w').write("{}") + ret = subprocess.check_output("./mustachetest").decode('utf8') + print(testfile, test["name"]) + if ret != test["expected"]: + if 'partials' in test: + print('partials:', json.dumps(test["partials"])) + print(json.dumps(test["data"])) + print(test["template"]) + print('Expected:',repr(test["expected"])) + print('Actual:',repr(ret)) + assert ret == test["expected"] + os.unlink('data') + os.unlink('template') + os.unlink('partials') |
