fix the tests error

This commit is contained in:
root 2020-06-24 17:34:49 +08:00
parent 167270e55d
commit 5d68afcb6b
3 changed files with 73 additions and 1 deletions

View File

@ -0,0 +1,22 @@
From 18219344a05a2db8aaa39f401567d18b9ffd57c6 Mon Sep 17 00:00:00 2001
Subject: fix the ImportManger infinite recursion
---
Cheetah/ImportManager.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/Cheetah/ImportManager.py b/Cheetah/ImportManager.py
index dbb2c96..d752755 100644
--- a/Cheetah/ImportManager.py
+++ b/Cheetah/ImportManager.py
@@ -21,6 +21,7 @@ import sys
import imp
import marshal
from Cheetah.compat import string_type
+import _bootlocale
_installed = False
--
2.23.0

View File

@ -0,0 +1,45 @@
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()

View File

@ -1,6 +1,6 @@
Name: python-cheetah
Version: 3.1.0
Release: 7
Release: 8
Summary: The Python-Powered Template Engine
License: MIT
URL: http://cheetahtemplate.org/
@ -9,6 +9,8 @@ BuildRequires: gcc python2-devel python2-setuptools python2-markdown python2-py
BuildRequires: python3-devel python3-setuptools python3-markdown python3-pygments
Patch0001: cheetah-3.0.0-dont-run-tests-twice.patch
Patch0002: fix-the-regressions-test-error.patch
Patch0003: fix-the-ImportManger-infinite-recursion.patch
%description
Cheetah3 is a free and open source template engine and code-generation tool written in Python.
@ -65,5 +67,8 @@ export PATH="%{buildroot}/%{_bindir}:$PATH" PYTHONPATH="%{buildroot}/%{python3_s
%{python3_sitearch}/
%changelog
* Wed Jun 24 2020 wangchong <wangchong56@huawei.com> - 3.1.0-8
- fix the tests error
* Wed Jan 8 2020 liujing<liujing144@huawei.com> - 3.1.0-7
- Package init