Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
bbc2547b
Commit
bbc2547b
authored
Jan 08, 2007
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more tests
parent
43d585ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
2 deletions
+38
-2
lib/python/Products/PageTemplates/tests/testZopePageTemplate.py
...thon/Products/PageTemplates/tests/testZopePageTemplate.py
+38
-2
No files found.
lib/python/Products/PageTemplates/tests/testZopePageTemplate.py
View file @
bbc2547b
...
...
@@ -11,12 +11,18 @@ Note: Tests require Zope >= 2.7
import
unittest
import
Zope2
import
transaction
import
zope.component.testing
from
zope.traversing.adapters
import
DefaultTraversable
from
zope.traversing.adapters
import
DefaultTraversable
,
Traverser
from
zope.publisher.http
import
HTTPCharsets
from
Testing.makerequest
import
makerequest
from
Testing.ZopeTestCase
import
ZopeTestCase
,
installProduct
from
Products.PageTemplates.ZopePageTemplate
import
ZopePageTemplate
,
manage_addPageTemplate
from
Products.PageTemplates.utils
import
encodingFromXMLPreamble
,
charsetFromMetaEquiv
from
zope.component
import
provideUtility
from
Products.PageTemplates.interfaces
import
IUnicodeEncodingConflictResolver
from
Products.PageTemplates.unicodeconflictresolver
import
PreferredCharsetResolver
ascii_str
=
'<html><body>hello world</body></html>'
...
...
@@ -76,7 +82,36 @@ class ZPTUtilsTests(unittest.TestCase):
self
.
assertEqual
(
extract
(
'<html><META http-equiv="content-type" content="text/html; charset=iso-8859-15"></html>'
),
'iso-8859-15'
)
self
.
assertEqual
(
extract
(
'<html><META http-equiv="content-type" content="text/html"></html>'
),
None
)
self
.
assertEqual
(
extract
(
'<html>...<html>'
),
None
)
class
ZPTUnicodeEncodingConflictResolution
(
ZopeTestCase
):
def
setUp
(
self
):
super
(
ZPTUnicodeEncodingConflictResolution
,
self
).
setUp
()
zope
.
component
.
provideAdapter
(
DefaultTraversable
,
(
None
,))
zope
.
component
.
provideAdapter
(
HTTPCharsets
,
(
None
,))
provideUtility
(
PreferredCharsetResolver
,
IUnicodeEncodingConflictResolver
)
def
testISO_8859_15
(
self
):
manage_addPageTemplate
(
self
.
app
,
'test'
,
text
=
'<div tal:content="python: request.get(
\
'
data
\
'
)" />'
,
encoding
=
'ascii'
)
zpt
=
self
.
app
[
'test'
]
self
.
app
.
REQUEST
.
set
(
'HTTP_ACCEPT_CHARSET'
,
'ISO-8859-15,utf-8'
)
self
.
app
.
REQUEST
.
set
(
'data'
,
''
)
result
=
zpt
.
pt_render
()
self
.
assertEqual
(
result
.
startswith
(
unicode
(
'<div></div>'
,
'iso-8859-15'
)),
True
)
def
testUTF8
(
self
):
manage_addPageTemplate
(
self
.
app
,
'test'
,
text
=
'<div tal:content="python: request.get(
\
'
data
\
'
)" />'
,
encoding
=
'ascii'
)
zpt
=
self
.
app
[
'test'
]
self
.
app
.
REQUEST
.
set
(
'HTTP_ACCEPT_CHARSET'
,
'ISO-8859-15,utf-8'
)
self
.
app
.
REQUEST
.
set
(
'data'
,
unicode
(
''
,
'iso-8859-15'
).
encode
(
'utf-8'
))
result
=
zpt
.
pt_render
()
self
.
assertEqual
(
result
.
startswith
(
unicode
(
'<div></div>'
,
'iso-8859-15'
)),
True
)
class
ZopePageTemplateFileTests
(
ZopeTestCase
):
...
...
@@ -274,6 +309,7 @@ def test_suite():
suite
.
addTests
(
unittest
.
makeSuite
(
ZPTUtilsTests
))
suite
.
addTests
(
unittest
.
makeSuite
(
ZPTMacros
))
suite
.
addTests
(
unittest
.
makeSuite
(
ZopePageTemplateFileTests
))
suite
.
addTests
(
unittest
.
makeSuite
(
ZPTUnicodeEncodingConflictResolution
))
return
suite
if
__name__
==
'__main__'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment