diff options
| author | Julien Phalip <jphalip@gmail.com> | 2013-02-14 23:29:15 -0800 |
|---|---|---|
| committer | Julien Phalip <jphalip@gmail.com> | 2013-02-14 23:29:15 -0800 |
| commit | 7d5e35cdb46124e2471833b9570add1a00a1d9e0 (patch) | |
| tree | 621ee04faadacfd0496eba9a80ea7d1bc9976980 /tests | |
| parent | f5e4a699ca0f58818acbdf9081164060cee910fa (diff) | |
Fixed #19829 -- Fixed index lookups for NumPy arrays in templates.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/templates/tests.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index 8d2a45b8fc..255671435a 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -54,6 +54,12 @@ except ImportError as e: else: raise +# NumPy installed? +try: + import numpy +except ImportError: + numpy = False + from . import filters ################################# @@ -1649,6 +1655,17 @@ class Templates(TestCase): 'verbatim-tag05': ('{% verbatim %}{% endverbatim %}{% verbatim %}{% endverbatim %}', {}, ''), 'verbatim-tag06': ("{% verbatim special %}Don't {% endverbatim %} just yet{% endverbatim special %}", {}, "Don't {% endverbatim %} just yet"), } + + if numpy: + tests.update({ + # Numpy's array-index syntax allows a template to access a certain item of a subscriptable object. + 'numpy-array-index01': ("{{ var.1 }}", {"var": numpy.array(["first item", "second item"])}, "second item"), + + # Fail silently when the array index is out of range. + 'numpy-array-index02': ("{{ var.5 }}", {"var": numpy.array(["first item", "second item"])}, ("", "INVALID")), + }) + + return tests class TemplateTagLoading(unittest.TestCase): |
