summaryrefslogtreecommitdiff
path: root/test/test_template.py
Commit message (Collapse)AuthorAgeFilesLines
* additional test_exceptions fixesMike Bayer2022-05-081-11/+8
| | | | | | | | | | | | | | Various fixes to the test suite in the area of exception message rendering to accommodate for variability in Python versions as well as Pygments. builds on 9b8da4b1e2bdc025b643f2061aa32 which also reduced some of the checks for exception message formatting. also updates black to 22.3.0 as there seem to be some dependency issues with the older version Fixes: #360 Change-Id: Ib8916534699e7c57817cf82d53300e50d47d0d50
* Refactor test.util into mako.testingMichael Bourke2022-01-141-26/+31
| | | | | Fixes: #349 Change-Id: I202c252a913fb72cc328a6e7f0f33174802487d3
* Remove Python 2 residue; use Python 3 idiomsMichael Bourke2021-12-271-2/+0
| | | | | | Fixes #352 Change-Id: I051ec20505464559e9399a8f1ac4a39dc323902a
* Fix exception causes in lookup.pyRam Rachum2021-12-091-8/+8
| | | | | | | | | | | | | | | | | | Mako now performs exception chaining using ``raise from``, correctly identifying underlying exception conditions when it raises its own exceptions. Pull request courtesy Ram Rachum. Additionally includes cleanup of the test suite to include better exception fixtures. Closes: #319 Pull-request: https://github.com/sqlalchemy/mako/pull/319 Pull-request-sha: d06526ac3f80ca9d24cd8143d8afde254f80b094 Additionally: Fixes: #348 Change-Id: Ibb2864de822bf4b63adf22a6bb32cf0758d296bd
* Fix matching multiline control lines in templates with CRLF line endingsCharles Pigott2021-11-131-0/+17
| | | | | | | | | | | | | | | | | | | | | Fixed issue where control statements on multi lines with a backslash would not parse correctly if the template itself contained CR/LF pairs as on Windows. Pull request courtesy Charles Pigott. A missing '\\' meant that it would actually allow ``` % if foo \r bar: ``` in a template file and not match if the file actually had a `\r` char Closes: #346 Pull-request: https://github.com/sqlalchemy/mako/pull/346 Pull-request-sha: e79ebabe3df7e59c9ea40e62406131e1a0c6c3b4 Change-Id: I179bdd661cecb1ffb3cf262e31183c8e83d98f12
* update black and formatFederico Caselli2021-10-251-9/+12
| | | | | | | | Closes: #342 Pull-request: https://github.com/sqlalchemy/mako/pull/342 Pull-request-sha: 21a068103481410cf4856fb07c19146dc684d460 Change-Id: I9027433ec23ee19c9d9a47015e0327acf409e2d8
* more code updatesMike Bayer2021-10-251-26/+1
| | | | | | | | | | | - 2021 copyright - remove unneeded compat functions - remove unneeded filter constructs - bytestring_passthrough mode doesn't actually do anything, as Py3k StringIO doesn't accept bytes in any case, remove this - should we call ourselves 2.0 and do semver ? Change-Id: I8a8cb5e78037b758e58c87d5d7b4f66b6c211419
* Modernize codeworkflow_test_initial_1_2Federico Caselli2021-10-231-322/+140
| | | | | | | | | | | - remove python 2 support - add github workflows - remove disable unicode - cleanup compat file - modernize setup - use pep517 Change-Id: Ic38dbf478046cec5d0815b468f0c235b4ea5e20c
* dont intefere with mako.templates in the test suiteMike Bayer2021-08-191-0/+1
| | | | | | | | Fixed some issues with running the test suite which would be revealed by running tests in random order. Fixes: #338 Change-Id: I90c2a86f9279a265f64b75be3a7af314ab8772ba
* Switch template encoding to utf-8Mike Bayer2020-05-291-5/+3
| | | | | | | | | The default template encoding is now utf-8. Previously, the encoding was "ascii", which was standard throughout Python 2. This allows that "magic encoding comment" for utf-8 templates is no longer required. Fixes: #267 Change-Id: I411a75ebd6161e2517e06b5180a3571e5f5d923e
* Use tox / zimportsMike Bayer2019-05-311-431/+918
| | | | Change-Id: Ia047c7052a6d242c2cf1c7a83981f1e38ea4d928
* Remove redundant Python<2.6 codeHugo2018-01-161-4/+1
| | | | | | | | | | | | | | | | | | | | | Includes PR https://github.com/zzzeek/mako/pull/26 so [Travis CI passes](https://travis-ci.org/hugovk/mako/builds/329346809). The last two commits are unique to this PR. --- Since Mako 1.0.0, Python 2.6 has been the minimum supported version: > [general] Compatibility changes; in order to modernize the codebase, Mako is now dropping support for Python 2.4 and Python 2.5 altogether. The source base is now targeted at Python 2.6 and forwards. http://docs.makotemplates.org/en/latest/changelog.html#change-b602a175c0ec26eaa4f42962d23cca96 This removes redundant code only relevant to Python 2.5 or earlier. It also adds `python_requires` to setup.py, so pip won't install this version on Python 2.5 or earlier. For people with older versions, pip will install the next Mako version down. Are all Python 3.x versions supported? If not, I'll add those to `python_requires` as well. Change-Id: I624e1d56e79555c579278c7a5b4de9498179ffe9 Pull-request: https://github.com/zzzeek/mako/pull/27
* Add include_error_handler parameter.Huayi Zhang2016-11-081-0/+15
| | | | | | | | This works like error_handler but is specific to a template when included in another using the include tag. Change-Id: Ie5506a8cba42c71519c703eacc82050902b9ceba Pull-request: https://bitbucket.org/zzzeek/mako/pull-requests/22
* - ensure that STOP_RENDERING is set up everywhere it needs to beMike Bayer2015-03-251-11/+13
|
* Add STOP_RENDERING keyword; exiting of a template.Cody Taylor2015-03-241-2/+15
| | | | Signed-off-by: Cody Taylor <codemister99@yahoo.com>
* fix test on win32Gabi Davar2015-01-271-1/+1
| | | | (cherry picked from commit 41be41e72522d71792bdbbdc391ad983af88d0a5)
* - correct some misconceptions in how the new lineno thing was built;Mike Bayer2014-06-081-6/+35
| | | | | record all linenos fully and track printed line numbers accurately wrt buffered lines and such.
* - fix the line number scheme to be consistently 1-based, bothMike Bayer2014-05-211-1/+27
| | | | | | | for the template and the module - turn full_line_map into a list - add another start source to help with when a render callable begins
* - remove creation of blank "x" fileMike Bayer2013-12-261-4/+16
|
* - [bug] Cleaned up all the various deprecation/Mike Bayer2013-04-131-4/+5
| | | | | | file warnings when running the tests under various Pythons with warnings turned on. [ticket:213]
* - [feature] Added lexer_cls argument to Template,Mike Bayer2012-11-121-3/+33
| | | | | TemplateLookup, allows alternate Lexer classes to be used.
* fixMike Bayer2012-11-111-1/+1
|
* - first pass at running a py3k compatible base in py2k as well.Mike Bayer2012-11-111-95/+93
| | | | | having some weird unicode issues I can't debug; the meaning of str.encode() seems to be changing globally somehow
* Finalized future_imports feature.Benjamin Trofatter2012-11-101-1/+1
| | | | | Changed keyword argument from futures to future_imports for clarity. Added docstring describing use.
* Added futures support to makoBenjamin Trofatter2012-11-091-0/+7
| | | | | | Provide a list of names to import from __future__ to Template or TemplateLookup, and it will render the import from __future__ statement at the top of the generated code so that it actually works.
* - clean up test exclusionsMike Bayer2012-09-051-108/+109
|
* - remove context manager to allow 2.5 and 2.4 to work, [ticket:188]Mike Bayer2012-04-131-3/+6
| | | | | - add conditionals to pygments-dependent tests that ensure pygments 1.4, separate check for no pygments.
* - add the final patch for #146Mike Bayer2012-04-061-0/+98
|
* - [feature] Control lines with no bodies willMike Bayer2012-04-031-1/+76
| | | | | | now succeed, as "pass" is added for these when no statements are otherwise present. Courtesy Ben Trofatter [ticket:146]
* - UNDEFINED is a reserved word too, fix docs, add testsrel_0_7_0Mike Bayer2012-03-301-1/+32
|
* py3k fixesrel_0_6_2Mike Bayer2012-02-021-4/+12
|
* - [feature] Added module_writer argument to Template,Mike Bayer2012-01-161-0/+21
| | | | | | | TemplateLookup, allows a callable to be passed which takes over the writing of the template's module source file, so that special environment-specific steps can be taken. [ticket:181]
* - [bug] The exception message in the html_error_templateMike Bayer2012-01-161-0/+17
| | | | is now escaped with the HTML filter. [ticket:142]
* - A Template is explicitly disallowedrel_0_5_0Mike Bayer2011-09-271-3/+20
| | | | | | | | | | | | | | | | | | | from having a url that normalizes to relative outside of the root. That is, if the Lookup is based at /home/mytemplates, an include that would place the ultimate template at /home/mytemplates/../some_other_directory, i.e. outside of /home/mytemplates, is disallowed. This usage was never intended despite the lack of an explicit check. The main issue this causes is that module files can be written outside of the module root (or raise an error, if file perms aren't set up), and can also lead to the same template being cached in the lookup under multiple, relative roots. TemplateLookup instead has always supported multiple file roots for this purpose. [ticket:174]
* - py3k fixesrel_0_4_0Mike Bayer2011-02-211-0/+4
|
* - the "ascii encoding by default" approach doesn't work in Py3K,Mike Bayer2011-02-211-1/+5
| | | | | | | | | because a string and an ascii encoded string are of course different things, and we'd like render() by default to return a string. So go the other way, use FEB in all cases, add a new flag bytestring_passthrough which goes back to StringIO, to support that one guy who wanted to force a bytestring through in an expression.
* - the keys() in the Context, as well asMike Bayer2011-02-201-4/+10
| | | | | | | | it's internal _data dictionary, now include just what was specified to render() as well as Mako builtins 'caller', 'capture'. The contents of __builtin__ are no longer copied.
* - use inlined getargspecMike Bayer2011-02-201-6/+27
| | | | | | | | | | | | | | | - The "output encoding" now defaults to "ascii", whereas previously it was set to None. This has the effect of FastEncodingBuffer being used internally by default when render() is called, instead of cStringIO or StringIO, which are slower, but allow bytestrings with unknown encoding to pass right through. It is of course not recommended to use bytestrings of unknown encoding. Usage of the "disable_unicode" mode also requires that output_encoding be set to None.
* - now that trailing whitespace comes up in red, need to get rid of itMike Bayer2011-01-191-66/+66
|
* - The range of Python identifiers thatMike Bayer2010-11-101-0/+98
| | | | | | | | | | | are considered "undefined", meaning they are pulled from the context, has been trimmed back to not include variables declared inside of expressions (i.e. from list comprehensions), as well as in the argument list of lambdas. This to better support the strict_undefined feature.
* - New flag on Template, TemplateLookup -Mike Bayer2010-11-091-2/+48
| | | | | | | strict_undefined=True, will cause variables not found in the context to raise a NameError immediately, instead of defaulting to the UNDEFINED value.
* petiteMike Bayer2010-07-131-44/+44
|
* - Windows paths are handled correctly if a TemplateMike Bayer2010-03-051-0/+63
| | | | | | | is passed only an absolute filename (i.e. with c: drive etc.) and no URI - the URI is converted to a forward-slash path and module_directory is treated as a windows path. [ticket:128]
* - The <%page args> tag can now be used in a baseMike Bayer2010-03-051-0/+53
| | | | | | | inheriting template - the full set of render() arguments are passed down through the inherits chain. Undeclared arguments go into **pageargs as usual. [ticket:116]
* - Template accepts empty control structure, i.e.Mike Bayer2010-03-051-1/+11
| | | | | % if: %endif, etc. [ticket:94] - finished cleanup for codegen.py, [ticket:98]
* - merged -r481:499 of py3k branch.Mike Bayer2010-03-041-72/+151
| | | | | | - Python 3 support is added ! See README.py3k for installation and testing notes. [ticket:119]
* - ensure lru threading test doesn't runMike Bayer2010-03-021-0/+23
| | | | | | | | | | | - Source code escaping has been simplified. In particular, module source files are now generated with the Python "magic encoding comment", and source code is passed through mostly unescaped, except for that code which is regenerated from parsed Python source. This fixes usage of unicode in <%namespace:defname> tags. [ticket:99]
* begin to modernize testing. in particular, get rid of test_htdocs as well ↵Mike Bayer2010-03-021-185/+240
| | | | | | | as ad-hoc HTML file writing, consistently cleanup the modules/cache directories, use nose skiptests for unsupported features.
* some more unicode testsMike Bayer2010-03-021-1/+31
|
* - Unit tests now run with nose. [ticket:127]Mike Bayer2010-02-051-0/+479