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
0c14ff7d
Commit
0c14ff7d
authored
Apr 10, 2010
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport r110704, suppressing deprecation for multifile.
parent
77502396
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
18 deletions
+7
-18
src/OFS/tests/testRanges.py
src/OFS/tests/testRanges.py
+7
-18
No files found.
src/OFS/tests/testRanges.py
View file @
0c14ff7d
...
@@ -178,9 +178,8 @@ class TestRequestRange(unittest.TestCase):
...
@@ -178,9 +178,8 @@ class TestRequestRange(unittest.TestCase):
def
expectMultipleRanges
(
self
,
range
,
sets
,
draft
=
0
):
def
expectMultipleRanges
(
self
,
range
,
sets
,
draft
=
0
):
import
cStringIO
import
cStringIO
from
mimetools
import
Message
from
multifile
import
MultiFile
import
re
import
re
import
email
rangeParse
=
re
.
compile
(
'bytes
\
s*(
\
d+)-(
\
d+)/(
\
d+)'
)
rangeParse
=
re
.
compile
(
'bytes
\
s*(
\
d+)-(
\
d+)/(
\
d+)'
)
req
=
self
.
app
.
REQUEST
req
=
self
.
app
.
REQUEST
rsp
=
req
.
RESPONSE
rsp
=
req
.
RESPONSE
...
@@ -211,20 +210,16 @@ class TestRequestRange(unittest.TestCase):
...
@@ -211,20 +210,16 @@ class TestRequestRange(unittest.TestCase):
# Decode the multipart message
# Decode the multipart message
bodyfile
=
cStringIO
.
StringIO
(
'Content-Type: %s
\
n
\
n
%s'
%
(
bodyfile
=
cStringIO
.
StringIO
(
'Content-Type: %s
\
n
\
n
%s'
%
(
rsp
.
getHeader
(
'content-type'
),
body
))
rsp
.
getHeader
(
'content-type'
),
body
))
bodymessage
=
Message
(
bodyfile
)
partmessages
=
[
part
partfiles
=
MultiFile
(
bodyfile
)
for
part
in
email
.
message_from_file
(
bodyfile
).
walk
()]
partfiles
.
push
(
bodymessage
.
getparam
(
'boundary'
))
partmessages
=
[]
add
=
partmessages
.
append
while
partfiles
.
next
():
add
(
Message
(
cStringIO
.
StringIO
(
partfiles
.
read
())))
# Check the different parts
# Check the different parts
returnedRanges
=
[]
returnedRanges
=
[]
add
=
returnedRanges
.
append
add
=
returnedRanges
.
append
for
part
in
partmessages
:
for
part
in
partmessages
:
range
=
part
[
'content-range'
]
if
part
.
get_content_maintype
()
==
'multipart'
:
continue
range
=
part
.
get
(
'content-range'
)
start
,
end
,
size
=
rangeParse
.
search
(
range
).
groups
()
start
,
end
,
size
=
rangeParse
.
search
(
range
).
groups
()
start
,
end
,
size
=
int
(
start
),
int
(
end
),
int
(
size
)
start
,
end
,
size
=
int
(
start
),
int
(
end
),
int
(
size
)
end
=
end
+
1
end
=
end
+
1
...
@@ -233,13 +228,7 @@ class TestRequestRange(unittest.TestCase):
...
@@ -233,13 +228,7 @@ class TestRequestRange(unittest.TestCase):
'Part Content-Range header reported incorrect length. '
'Part Content-Range header reported incorrect length. '
'Expected %d, got %d.'
%
(
len
(
self
.
data
),
size
))
'Expected %d, got %d.'
%
(
len
(
self
.
data
),
size
))
part
.
rewindbody
()
body
=
part
.
get_payload
()
body
=
part
.
fp
.
read
()
# Whotcha! Bug in MultiFile; the CRLF that is part of the boundary
# is returned as part of the body. Note that this bug is resolved
# in Python 2.2.
if
body
[
-
2
:]
==
'
\
r
\
n
'
:
body
=
body
[:
-
2
]
self
.
failIf
(
len
(
body
)
!=
end
-
start
,
self
.
failIf
(
len
(
body
)
!=
end
-
start
,
'Part (%d, %d) is of wrong length, expected %d, got %d.'
%
(
'Part (%d, %d) is of wrong length, expected %d, got %d.'
%
(
...
...
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