aboutsummaryrefslogtreecommitdiffstats
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* Switch template encoding to utf-8Mike Bayer2020-05-295-9/+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 unittest.SkipTest (again?)Michał Górny2020-03-022-12/+7
| | | | | | | | | | | | | While I can believe that the standard exception might not have worked with some ancient version of pytest, it certainly works just fine now. This saves people from importing nose which kills pytest via DeprecationWarnings these days. Closes: #316 Pull-request: https://github.com/sqlalchemy/mako/pull/316 Pull-request-sha: 90dfcfc3d0351ab9bf8125e8c2adb45c57059a6d Change-Id: Ie816acd325c6783e08801bc83de37dbe6b4581e5
* Replace usage of parser.suite with ast.parseMike Bayer2020-01-052-2/+2
| | | | | | | | | | | | | | Replaced usage of the long-superseded "parser.suite" module in the mako.util package for parsing the python magic encoding comment with the "ast.parse" function introduced many years ago in Python 2.5, as "parser.suite" is emitting deprecation warnings in Python 3.9. Additionally repair two error-detection unit tests that were using a "print" statement despite the tests running under Python 3; while the tests were passing they were no longer testing the right thing. Fixes: #310 Change-Id: Id436e2c6620438ef16b3f188b989233c82972b29
* Bump Python versions, remove conditional importsMike Bayer2019-07-271-2/+1
| | | | | | | | | | | | | | | | | | | | | | Mako 1.1 now supports Python versions: * 2.7 * 3.4 and higher This includes that setup.py no longer includes any conditionals, allowing for a pure Python wheel build, however this is not necessarily part of the Pypi release process as of yet. The test suite also raises for Python deprecation warnings. Fixes: #249 Replaced usage of ``inspect.getfullargspec()`` with the vendored version used by SQLAlchemy, Alembic to avoid future deprecation warnings. Also cleans up an additional version of the same function that's apparently been floating around for some time. Fixes: #295 Change-Id: I98274c16b6022289d1890f4daf532bab323ab112
* Merge "Include URI in traceback if filename is unknown"mike bayer2019-07-081-6/+44
|\
| * Include URI in traceback if filename is unknownMartin von Gagern2019-07-081-6/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using URIs as entrered will make the stack trace arguably more readable than using the module name which is the URI with non-word characters replaced by underscores. This change also fixes a mistake where a mods cache hit would not update template_filename, causing a stale filename to be displayed if the stack trace alternates between different templates. There now is a test case for this. Closes: #298 Pull-request: https://github.com/sqlalchemy/mako/pull/298 Pull-request-sha: ea35208d504932561711cdb574ec1f7def1e7060 Change-Id: Ieb606f6b6b7f4602d4d56694dd0bccf6dc287d20
* | Support n filter in the page tagMartin von Gagern2019-07-081-0/+11
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | In some situations, it is inconvenient to pass default_filters in the Template constructor depending on the template in question. It might be easier in such situations to express page filters in the template itself. However, dropping the existing default_filters (either explicitly set or the default of ["str"] resp. ["unicode"]) might break existing templates. The code change here comes to the rescue in such situations. Existing templates keep working as they are, but editors of templates get a tool to replace the default filters for specific templates. They do take on the responsibility of turning all encountered inputs into strings, lest they fail along the lines of https://github.com/sqlalchemy/mako/issues/272. This change should be sufficiently backwards compatible to not cause any concerns. Sure, technically a "n" filter at page tag level was treated as a no-op so far. So theoretically existing templates could break. But there was no incentive to have such an "n" filter at the page tag level, and the expressed semantics of the "n" filter is to suppress default filters, so semantically anyone relying on it being a no-op in that situation was using unsupported hacks anyway. Closes: #299 Pull-request: https://github.com/sqlalchemy/mako/pull/299 Pull-request-sha: f8d5a22db3230634d2b42c59909985f31875a9f5 Change-Id: Ide030975229c1df7c0cef534976f740a03c17ca6
* Correctly track line numbers for multi-line code blocksMartin von Gagern2019-07-011-0/+48
| | | | | | | | | | | | | | | | Improved the line-number tracking for source lines inside of Python ``<% ... %>`` blocks, such that text- and HTML-formatted exception traces such as that of :func:`.html_error_template` now report the correct source line inside the block, rather than the first line of the block itself. Exceptions in ``<%! ... %>`` blocks which get raised while loading the module are still not reported correctly, as these are handled before the Mako code is generated. Pull request courtesy Martin von Gagern. Closes: #297 Pull-request: https://github.com/sqlalchemy/mako/pull/297 Pull-request-sha: 60ad749604f8de0a9b8133430995045a93d0939c Change-Id: I2086e4370e8e2db7099de01743840286f0160efc
* Remove all non-essential functions from _ast_util.pyMike Bayer2019-06-031-4/+12
| | | | | | | | | | | | | As this is an old module that keeps changing with new Python releases, combined with the fact that we no longer use "import *", remove all unused functions from this module so that the list of imports we are maintaining is much shorter. Python 3.8 is also added to tox.ini with more adjustments to test_exceptions to accommodate for quoting differences. Fixes: #296 Change-Id: I0cea7d21ecb2be9335e0845ae7fbd06d468a137b
* Use tox / zimportsMike Bayer2019-05-3127-2470/+4179
| | | | Change-Id: Ia047c7052a6d242c2cf1c7a83981f1e38ea4d928
* Use utf-8 encoding for traceback source with no encoding in py3kMike Bayer2019-05-092-0/+17
| | | | | | | | | | Added a default encoding of "utf-8" when the :class:`.RichTraceback` object retrieves Python source lines from a Python traceback; as these are bytes in Python 3 they need to be decoded so that they can be formatted in the template. Fixes: #293 Change-Id: I41a5c09422d6500c7cab2423ed14ac951a64e2f4
* Remove redundant Python<2.6 codeHugo2018-01-163-12/+3
| | | | | | | | | | | | | | | | | | | | | 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
* - exception test fixes for more recent pygmentsMike Bayer2017-05-221-2/+2
| | | | Change-Id: Ibdfe5b2f2f3d1426921bcadf6740ae065ed0833b
* 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
* - disable some beaker tests that fail for 2.6Mike Bayer2016-03-091-1/+3
|
* - reduce the pygments strings we're searching for to accommodate forMike Bayer2016-03-091-26/+8
| | | | | | changes in pygments formatting; we might be losing a bit of what was tested here originally but we still assert pygments is taking place.
* Merge remote-tracking branch 'github/pr/19'Mike Bayer2016-03-091-2/+15
|\
| * Improve lexer with better string handling and grouping parens/bracketsDaniel Martin2016-02-041-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows the lexer to correctly handle strings like: ${'backslash quote right-curly is \\\'}'} And also allows users to use the bitwise-or operator to mean bitwise or simply by enclosing the expression inside parens: ${(0x5432 | 0x8000)} or by using it in the middle of a dictionary literal: ${ {'foo-val': 0x43 | 0x100, 'bar-val': 0x22 | 0x100}[thing+'-val']} or inside brackets: ${ big_lookup_dict[index_low | (indexhigh << 3)] } Basically, only "top level" uses of the vertical bar mean pipe. (Note that currently, any non-top-level use of the vertical bar in an expression just results in a syntax error in the generated python, so no working code is affected by this change)
* | Merge branch 'feature-list_defs' of https://bitbucket.org/jvanasco/mako into ↵Mike Bayer2016-03-091-0/+35
|\ \ | |/ |/| | | pr16
| * added testsjonathan vanasco2015-03-251-0/+35
| |
* | - still supporting py2.6 hereMike Bayer2015-10-261-2/+2
| |
* | Ensure babel i18n extactor works properly with non-ascii inputRoman Imankulov2015-10-133-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If mako templates contain something like "_('Köln')", babel extractor converts it to pure ASCII so that resulting .po file would contain "K\xf6ln". Not all translation tools and translations are ready for such kind of escape sequences. Babel allows message ids to be non-ascii, the plugin just has to return Unicode objects instead of ASCII strings (and that's exactly how Babel built-in Python and JavaScript extractors work). This fix ensures mako extractor doesn't excape non-ascii symbols, works well both for Unicode and non-unicode input (there is a test for cp1251 encoding), and also provides a workaround for babel charset detector python-babel/babel#274.
* | correct template lookup on Windows:Gabi Davar2015-08-271-4/+3
| | | | | | | | | | | | - posixpath.join does not handle windows paths very well. Now all tests pass on py27 & py34 on windows.
* | - use a SkipTest pytest can findMike Bayer2015-07-261-1/+3
| |
* | The Lingua extractor must not generate a parse error in case of extra blank ↵Laurent DAVERIO2015-05-141-0/+3
| | | | | | | | spaces inside curly brackets.
* | Lingua extractor silently ignores try/except blocks instead or returning an ↵Laurent DAVERIO2015-05-041-1/+9
| | | | | | | | error.
* | Added test cases for gettext extraction: `for/else` and `while` blocks.Laurent DAVERIO2015-05-041-1/+11
| |
* | Provide a testcase for pull request #18.ldaverio2015-05-011-0/+10
| |
* | - 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)
* - py3k adjustments for babel/linguaMike Bayer2015-01-221-14/+16
|
* - reorganize cache tests so that we have distinct series for beaker,Mike Bayer2015-01-221-103/+208
| | | | | dogpile, "generic" - stress dogpile a bit more in caching docs
* - make this import more specific, on a py3k pip uninstall of babelMike Bayer2015-01-221-1/+1
| | | | these symbols still seem to be hanging around
* - reimplement skiptests for babel or lingua not installedMike Bayer2015-01-224-36/+72
| | | | - remove nose dependency
* Use new lingua extractor APIWichert Akkerman2014-08-261-11/+35
| | | | This gives a saner way to call into lingua's Python extractor.
* Merge babel test files.Wichert Akkerman2014-08-262-50/+36
|
* Add lingua pluginWichert Akkerman2014-08-251-0/+19
|
* Split core extraction logic out of babel pluginWichert Akkerman2014-08-251-21/+0
|
* Add tests for Babel pluginWichert Akkerman2014-08-252-0/+48
|
* - 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
* url escape filter for non-unicodeXie Shi2014-05-041-0/+22
|
* - use py3.3's unittest.mock if availableMike Bayer2014-04-282-3/+7
|
* - will now be 1.0Mike Bayer2014-04-282-8/+2
| | | | | - drop python 2.4, 2.5 support - various pep8ing
* - switch to argparse for cmdline template runnerMike Bayer2014-04-285-11/+93
| | | | | | | - write a test suite for cmdline - start using context manager helpers in tests. intrinsic here is that we're going to go 1.0 and drop at least 2.4 and probably 2.5 - update .gitignore
* - add addtional test, py2K only, for when and object's __str__() method returnsMike Bayer2014-04-211-0/+13
| | | | | | non-ASCII bytes. This is invalid on py3K as __str__() must return a string. send the object through the function recursively when we get the __str__() value.
* - Fixed bug in ``decode.<encoding>`` filter where a non-string objectMike Bayer2014-04-201-1/+10
| | | | | | | would not be correctly interpreted in Python 3. Conflicts: doc/build/changelog.rst
* - add py.test settingsMike Bayer2014-04-131-3/+3
| | | | - fix this update_wrapper thing so tests are reported nicely
* - Fixed bug in Python parsing logic which would fail on Python 3Mike Bayer2014-04-131-1/+24
| | | | | when a "try/except" targeted a tuple of exception types, rather than a single exception. fixes #227