Skip to content

Commit

Permalink
additional test_exceptions fixes
Browse files Browse the repository at this point in the history
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 9b8da4b 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
  • Loading branch information
zzzeek committed May 9, 2022
1 parent 9b8da4b commit eae8e3a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/python/black
rev: 21.9b0
rev: 22.3.0
hooks:
- id: black

Expand Down
6 changes: 6 additions & 0 deletions doc/build/unreleased/360.rst
@@ -0,0 +1,6 @@
.. change::
:tags: bug, tests
:tickets: 360

Various fixes to the test suite in the area of exception message rendering
to accommodate for variability in Python versions as well as Pygments.
2 changes: 1 addition & 1 deletion examples/bench/django/templatetags/bench.py
@@ -1,4 +1,4 @@
from django.template import Library, Node, resolve_variable
from django.template import Library
from django.utils.html import escape

register = Library()
Expand Down
9 changes: 7 additions & 2 deletions examples/wsgi/run_wsgi.py
@@ -1,7 +1,12 @@
#!/usr/bin/python
import cgi, re, os, posixpath, mimetypes
from mako.lookup import TemplateLookup
import cgi
import mimetypes
import os
import posixpath
import re

from mako import exceptions
from mako.lookup import TemplateLookup

root = "./"
port = 8000
Expand Down
2 changes: 1 addition & 1 deletion test/test_exceptions.py
Expand Up @@ -173,7 +173,7 @@ def test_format_exceptions_pygments(self):
)

assert (
'<div class="sourceline"><table class="syntax-highlightedtable">'
'<table class="syntax-highlightedtable">'
in l.get_template("foo.html").render_unicode()
)

Expand Down
19 changes: 8 additions & 11 deletions test/test_template.py
Expand Up @@ -940,18 +940,15 @@ def test_control(self):
%endfor
"""
)
assert (
result_lines(
t.render(
y=[
{"test": "one"},
{"foo": "bar"},
{"foo": "bar", "test": "two"},
]
)
assert result_lines(
t.render(
y=[
{"test": "one"},
{"foo": "bar"},
{"foo": "bar", "test": "two"},
]
)
== ["yes x has test", "no x does not have test", "yes x has test"]
)
) == ["yes x has test", "no x does not have test", "yes x has test"]

def test_blank_control_1(self):
self._do_memory_test(
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Expand Up @@ -30,7 +30,7 @@ deps=
pydocstyle<4.0.0
# used by flake8-rst-docstrings
pygments
black==21.9b0
black==22.3.0
commands =
flake8 ./mako/ ./test/ setup.py --exclude test/templates,test/foo {posargs}
black --check .

0 comments on commit eae8e3a

Please sign in to comment.