46 lines
1.6 KiB
Diff
46 lines
1.6 KiB
Diff
|
|
From 43de6576d55bfcbdbc51e065f5df78fb8da83023 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Oleg Broytman <phd@phdru.name>
|
||
|
|
Date: Sat, 6 Apr 2019 17:25:30 +0300
|
||
|
|
Subject: [PATCH] Tests: Use `cgi.escape` for Py2, `html.escape` for Py3
|
||
|
|
|
||
|
|
---
|
||
|
|
Cheetah/Tests/Regressions.py | 11 +++++++----
|
||
|
|
1 files changed, 7 insertions(+), 4 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/Cheetah/Tests/Regressions.py b/Cheetah/Tests/Regressions.py
|
||
|
|
index b380e6d..b72fd77 100755
|
||
|
|
--- a/Cheetah/Tests/Regressions.py
|
||
|
|
+++ b/Cheetah/Tests/Regressions.py
|
||
|
|
@@ -1,5 +1,10 @@
|
||
|
|
#!/usr/bin/env python
|
||
|
|
|
||
|
|
+try:
|
||
|
|
+ from cgi import escape as html_escape
|
||
|
|
+except ImportError: # Python 3.8+
|
||
|
|
+ from html import escape as html_escape
|
||
|
|
+
|
||
|
|
import unittest
|
||
|
|
import Cheetah.NameMapper
|
||
|
|
import Cheetah.Template
|
||
|
|
@@ -138,18 +143,16 @@ class Mantis_Issue_11_Regression_Test(unittest.TestCase):
|
||
|
|
s = s.replace("&", "&") # Must be done first!
|
||
|
|
'''
|
||
|
|
def test_FailingBehavior(self):
|
||
|
|
- import cgi
|
||
|
|
template = Cheetah.Template.Template(
|
||
|
|
"$escape($request)",
|
||
|
|
- searchList=[{'escape': cgi.escape, 'request': 'foobar'}])
|
||
|
|
+ searchList=[{'escape': html_escape, 'request': 'foobar'}])
|
||
|
|
assert template
|
||
|
|
self.assertRaises(AttributeError, template.respond)
|
||
|
|
|
||
|
|
def test_FailingBehaviorWithSetting(self):
|
||
|
|
- import cgi
|
||
|
|
template = Cheetah.Template.Template(
|
||
|
|
"$escape($request)",
|
||
|
|
- searchList=[{'escape': cgi.escape, 'request': 'foobar'}],
|
||
|
|
+ searchList=[{'escape': html_escape, 'request': 'foobar'}],
|
||
|
|
compilerSettings={'prioritizeSearchListOverSelf': True})
|
||
|
|
assert template
|
||
|
|
assert template.respond()
|