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
ac81f0db
Commit
ac81f0db
authored
Jun 12, 2010
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qui custodiet custodiens?
parent
bae502cb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
5 deletions
+79
-5
src/Testing/ZopeTestCase/zopedoctest/functional.py
src/Testing/ZopeTestCase/zopedoctest/functional.py
+6
-1
src/Testing/ZopeTestCase/zopedoctest/testFunctionalDocTest.py
...Testing/ZopeTestCase/zopedoctest/testFunctionalDocTest.py
+73
-4
No files found.
src/Testing/ZopeTestCase/zopedoctest/functional.py
View file @
ac81f0db
...
...
@@ -39,6 +39,8 @@ from Testing.ZopeTestCase.functional import savestate
class
HTTPHeaderOutput
:
# zope.interface.implements(zope.server.interfaces.IHeaderOutput)
status
=
'200'
reason
=
'OK'
def
__init__
(
self
,
protocol
,
omit
):
self
.
headers
=
{}
...
...
@@ -57,7 +59,10 @@ class HTTPHeaderOutput:
))
def
appendResponseHeaders
(
self
,
lst
):
headers
=
[
split_header
(
header
)
for
header
in
lst
]
if
lst
and
isinstance
(
lst
[
0
],
basestring
):
headers
=
[
split_header
(
header
)
for
header
in
lst
]
else
:
headers
=
lst
self
.
headersl
.
extend
(
[(
'-'
.
join
([
s
.
capitalize
()
for
s
in
name
.
split
(
'-'
)]),
v
)
for
name
,
v
in
headers
...
...
src/Testing/ZopeTestCase/zopedoctest/testFunctionalDocTest.py
View file @
ac81f0db
...
...
@@ -11,17 +11,85 @@
#
##############################################################################
"""Example functional doctest
$Id$
"""
import
unittest
from
unittest
import
TestSuite
from
Testing.ZopeTestCase
import
installProduct
from
Testing.ZopeTestCase
import
FunctionalDocTestSuite
from
Testing.ZopeTestCase
import
FunctionalDocFileSuite
installProduct
(
'PythonScripts'
)
class
HTTPHeaderOutputTests
(
unittest
.
TestCase
):
def
_getTargetClass
(
self
):
from
Testing.ZopeTestCase.zopedoctest.functional
\
import
HTTPHeaderOutput
return
HTTPHeaderOutput
def
_makeOne
(
self
,
protocol
,
omit
):
return
self
.
_getTargetClass
()(
protocol
,
omit
)
def
test_ctor
(
self
):
hho
=
self
.
_makeOne
(
'HTTP/1.0'
,
())
self
.
assertEqual
(
hho
.
protocol
,
'HTTP/1.0'
)
self
.
assertEqual
(
hho
.
omit
,
())
self
.
assertEqual
(
hho
.
status
,
'200'
)
self
.
assertEqual
(
hho
.
reason
,
'OK'
)
self
.
assertEqual
(
hho
.
headers
,
{})
self
.
assertEqual
(
hho
.
headersl
,
[])
def
test_setResponseStatus
(
self
):
hho
=
self
.
_makeOne
(
'HTTP/1.0'
,
())
hho
.
setResponseStatus
(
'401'
,
'Unautnorized'
)
self
.
assertEqual
(
hho
.
status
,
'401'
)
self
.
assertEqual
(
hho
.
reason
,
'Unautnorized'
)
def
test_setResponseHeaders_no_omit
(
self
):
hho
=
self
.
_makeOne
(
'HTTP/1.0'
,
())
hho
.
setResponseHeaders
({
'Content-Type'
:
'text/html'
})
self
.
assertEqual
(
hho
.
headers
,
{
'Content-Type'
:
'text/html'
})
self
.
assertEqual
(
hho
.
headersl
,
[])
def
test_setResponseHeaders_w_omit
(
self
):
hho
=
self
.
_makeOne
(
'HTTP/1.0'
,
(
'content-type'
,))
hho
.
setResponseHeaders
({
'Content-Type'
:
'text/html'
})
self
.
assertEqual
(
hho
.
headers
,
{})
self
.
assertEqual
(
hho
.
headersl
,
[])
def
test_appendResponseHeaders_no_omit_tuples
(
self
):
hho
=
self
.
_makeOne
(
'HTTP/1.0'
,
())
hho
.
appendResponseHeaders
([(
'Content-Type'
,
'text/html'
)])
self
.
assertEqual
(
hho
.
headers
,
{})
self
.
assertEqual
(
hho
.
headersl
,
[(
'Content-Type'
,
'text/html'
)])
def
test_appendResponseHeaders_no_omit_strings
(
self
):
# Some Zope versions passed around headers as lists of strings.
hho
=
self
.
_makeOne
(
'HTTP/1.0'
,
())
hho
.
appendResponseHeaders
([(
'Content-Type: text/html'
)])
self
.
assertEqual
(
hho
.
headers
,
{})
self
.
assertEqual
(
hho
.
headersl
,
[(
'Content-Type'
,
'text/html'
)])
def
test_appendResponseHeaders_w_omit
(
self
):
hho
=
self
.
_makeOne
(
'HTTP/1.0'
,
(
'content-type'
,))
hho
.
appendResponseHeaders
([(
'Content-Type'
,
'text/html'
)])
self
.
assertEqual
(
hho
.
headers
,
{})
self
.
assertEqual
(
hho
.
headersl
,
[])
def
test___str___no_headers
(
self
):
hho
=
self
.
_makeOne
(
'HTTP/1.0'
,
(
'content-type'
,))
self
.
assertEqual
(
str
(
hho
),
'HTTP/1.0 200 OK'
)
def
test___str___w_headers
(
self
):
hho
=
self
.
_makeOne
(
'HTTP/1.0'
,
(
'content-type'
,))
hho
.
headers
[
'Content-Type'
]
=
'text/html'
hho
.
headersl
.
append
((
'Content-Length'
,
'23'
))
self
.
assertEqual
(
str
(
hho
),
'HTTP/1.0 200 OK
\
n
'
'Content-Length: 23
\
n
'
'Content-Type: text/html'
)
def
setUp
(
self
):
'''This method will run after the test_class' setUp.
...
...
@@ -58,7 +126,8 @@ def setUp(self):
def
test_suite
():
return
TestSuite
((
return
unittest
.
TestSuite
((
unittest
.
makeSuite
(
HTTPHeaderOutputTests
),
FunctionalDocTestSuite
(
setUp
=
setUp
),
FunctionalDocFileSuite
(
'FunctionalDocTest.txt'
,
setUp
=
setUp
),
))
...
...
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