Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e768c398
Commit
e768c398
authored
Aug 05, 2012
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CGI tests to take into account the platform's line ending (issue #13119)
parent
ec2d2693
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
Lib/test/test_httpservers.py
Lib/test/test_httpservers.py
+7
-5
No files found.
Lib/test/test_httpservers.py
View file @
e768c398
...
@@ -313,6 +313,8 @@ class CGIHTTPServerTestCase(BaseTestCase):
...
@@ -313,6 +313,8 @@ class CGIHTTPServerTestCase(BaseTestCase):
class
request_handler
(
NoLogRequestHandler
,
CGIHTTPRequestHandler
):
class
request_handler
(
NoLogRequestHandler
,
CGIHTTPRequestHandler
):
pass
pass
linesep
=
os
.
linesep
.
encode
(
'ascii'
)
def
setUp
(
self
):
def
setUp
(
self
):
BaseTestCase
.
setUp
(
self
)
BaseTestCase
.
setUp
(
self
)
self
.
cwd
=
os
.
getcwd
()
self
.
cwd
=
os
.
getcwd
()
...
@@ -410,7 +412,7 @@ class CGIHTTPServerTestCase(BaseTestCase):
...
@@ -410,7 +412,7 @@ class CGIHTTPServerTestCase(BaseTestCase):
def
test_headers_and_content
(
self
):
def
test_headers_and_content
(
self
):
res
=
self
.
request
(
'/cgi-bin/file1.py'
)
res
=
self
.
request
(
'/cgi-bin/file1.py'
)
self
.
assertEqual
((
b'Hello World
\
n
'
,
'text/html'
,
200
),
self
.
assertEqual
((
b'Hello World
'
+
self
.
linesep
,
'text/html'
,
200
),
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
def
test_post
(
self
):
def
test_post
(
self
):
...
@@ -419,7 +421,7 @@ class CGIHTTPServerTestCase(BaseTestCase):
...
@@ -419,7 +421,7 @@ class CGIHTTPServerTestCase(BaseTestCase):
headers
=
{
'Content-type'
:
'application/x-www-form-urlencoded'
}
headers
=
{
'Content-type'
:
'application/x-www-form-urlencoded'
}
res
=
self
.
request
(
'/cgi-bin/file2.py'
,
'POST'
,
params
,
headers
)
res
=
self
.
request
(
'/cgi-bin/file2.py'
,
'POST'
,
params
,
headers
)
self
.
assertEqual
(
res
.
read
(),
b'1, python, 123456
\
n
'
)
self
.
assertEqual
(
res
.
read
(),
b'1, python, 123456
'
+
self
.
linesep
)
def
test_invaliduri
(
self
):
def
test_invaliduri
(
self
):
res
=
self
.
request
(
'/cgi-bin/invalid'
)
res
=
self
.
request
(
'/cgi-bin/invalid'
)
...
@@ -430,20 +432,20 @@ class CGIHTTPServerTestCase(BaseTestCase):
...
@@ -430,20 +432,20 @@ class CGIHTTPServerTestCase(BaseTestCase):
headers
=
{
b'Authorization'
:
b'Basic '
+
headers
=
{
b'Authorization'
:
b'Basic '
+
base64
.
b64encode
(
b'username:pass'
)}
base64
.
b64encode
(
b'username:pass'
)}
res
=
self
.
request
(
'/cgi-bin/file1.py'
,
'GET'
,
headers
=
headers
)
res
=
self
.
request
(
'/cgi-bin/file1.py'
,
'GET'
,
headers
=
headers
)
self
.
assertEqual
((
b'Hello World
\
n
'
,
'text/html'
,
200
),
self
.
assertEqual
((
b'Hello World
'
+
self
.
linesep
,
'text/html'
,
200
),
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
def
test_no_leading_slash
(
self
):
def
test_no_leading_slash
(
self
):
# http://bugs.python.org/issue2254
# http://bugs.python.org/issue2254
res
=
self
.
request
(
'cgi-bin/file1.py'
)
res
=
self
.
request
(
'cgi-bin/file1.py'
)
self
.
assertEqual
((
b'Hello World
\
n
'
,
'text/html'
,
200
),
self
.
assertEqual
((
b'Hello World
'
+
self
.
linesep
,
'text/html'
,
200
),
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
def
test_os_environ_is_not_altered
(
self
):
def
test_os_environ_is_not_altered
(
self
):
signature
=
"Test CGI Server"
signature
=
"Test CGI Server"
os
.
environ
[
'SERVER_SOFTWARE'
]
=
signature
os
.
environ
[
'SERVER_SOFTWARE'
]
=
signature
res
=
self
.
request
(
'/cgi-bin/file1.py'
)
res
=
self
.
request
(
'/cgi-bin/file1.py'
)
self
.
assertEqual
((
b'Hello World
\
n
'
,
'text/html'
,
200
),
self
.
assertEqual
((
b'Hello World
'
+
self
.
linesep
,
'text/html'
,
200
),
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
self
.
assertEqual
(
os
.
environ
[
'SERVER_SOFTWARE'
],
signature
)
self
.
assertEqual
(
os
.
environ
[
'SERVER_SOFTWARE'
],
signature
)
...
...
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