Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rfc6266
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
rfc6266
Commits
138f55cd
Commit
138f55cd
authored
Jan 30, 2012
by
Gabriel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Spin off a test module.
parent
3419ddbd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
43 deletions
+46
-43
README
+1
-1
rfc6266.py
+1
-40
setup.py
+1
-1
test_rfc6266.py
+42
-0
tox.ini
+1
-1
No files found.
README
View file @
138f55cd
...
...
@@ -35,7 +35,7 @@ Currently tested under Python 2.7, Python 2.6, Python 3.2, and PyPy (1.7).
To test in the current Python implementation:
nosetests --
all-modules --
detailed-errors
nosetests --detailed-errors
To test with tox:
...
...
rfc6266.py
View file @
138f55cd
...
...
@@ -277,8 +277,7 @@ qdtext = AnyBut('"' + ctl_chars)
char
=
Any
(
''
.
join
(
chr
(
i
)
for
i
in
xrange
(
128
)))
# ascii range: 0-127
quoted_pair
=
Drop
(
'
\\
'
)
+
char
quoted_string
=
(
Drop
(
'"'
)
&
(
quoted_pair
|
qdtext
)[:,
...
]
&
Drop
(
'"'
)
)
#> parse_iso
quoted_string
=
Drop
(
'"'
)
&
(
quoted_pair
|
qdtext
)[:,
...
]
&
Drop
(
'"'
)
value
=
token
|
quoted_string
...
...
@@ -411,41 +410,3 @@ def build_header(
# This will only encode filename_compat, if it used non-ascii iso-8859-1.
return
rv
.
encode
(
'iso-8859-1'
)
def
test_parsing
():
assert
parse_headers
(
None
)
.
disposition
==
'inline'
assert
parse_headers
(
'attachment'
)
.
disposition
==
'attachment'
assert
parse_headers
(
'attachment; key=val'
)
.
assocs
[
'key'
]
==
'val'
assert
parse_headers
(
'attachment; filename=simple'
)
.
filename_unsafe
==
'simple'
# test ISO-8859-1
fname
=
parse_headers
(
u'attachment; filename="oyé"'
)
.
filename_unsafe
assert
fname
==
u'oyé'
,
repr
(
fname
)
cd
=
parse_headers
(
'attachment; filename="EURO rates";'
' filename*=utf-8
\'\'
%
e2
%82%
ac
%20
rates'
)
assert
cd
.
filename_unsafe
==
u'€ rates'
def
test_location_fallback
():
assert
parse_headers
(
None
,
location
=
'https://foo/bar
%
c3
%
a9.py'
)
.
filename_unsafe
==
u'baré.py'
def
test_roundtrip
():
def
roundtrip
(
filename
):
return
parse_headers
(
build_header
(
filename
))
.
filename_unsafe
def
assert_roundtrip
(
filename
):
assert
roundtrip
(
filename
)
==
filename
assert_roundtrip
(
'a b'
)
assert_roundtrip
(
'a b'
)
assert_roundtrip
(
'a b '
)
assert_roundtrip
(
' a b'
)
assert_roundtrip
(
'a
\"
b'
)
assert_roundtrip
(
u'aéio o♥u"qfsdf!'
)
setup.py
View file @
138f55cd
...
...
@@ -4,7 +4,7 @@ from setuptools import setup
setup
(
name
=
'rfc6266'
,
version
=
'0.0.1'
,
# symver
py_modules
=
[
'rfc6266'
],
py_modules
=
[
'rfc6266'
,
'test_rfc6266'
],
install_requires
=
[
'LEPL'
],
use_2to3
=
True
,
)
...
...
test_rfc6266.py
0 → 100644
View file @
138f55cd
# vim: set fileencoding=utf-8 sw=4 ts=4 et :
from
rfc6266
import
parse_headers
,
build_header
def
test_parsing
():
assert
parse_headers
(
None
)
.
disposition
==
'inline'
assert
parse_headers
(
'attachment'
)
.
disposition
==
'attachment'
assert
parse_headers
(
'attachment; key=val'
)
.
assocs
[
'key'
]
==
'val'
assert
parse_headers
(
'attachment; filename=simple'
)
.
filename_unsafe
==
'simple'
# test ISO-8859-1
fname
=
parse_headers
(
u'attachment; filename="oyé"'
)
.
filename_unsafe
assert
fname
==
u'oyé'
,
repr
(
fname
)
cd
=
parse_headers
(
'attachment; filename="EURO rates";'
' filename*=utf-8
\'\'
%
e2
%82%
ac
%20
rates'
)
assert
cd
.
filename_unsafe
==
u'€ rates'
def
test_location_fallback
():
assert
parse_headers
(
None
,
location
=
'https://foo/bar
%
c3
%
a9.py'
)
.
filename_unsafe
==
u'baré.py'
def
test_roundtrip
():
def
roundtrip
(
filename
):
return
parse_headers
(
build_header
(
filename
))
.
filename_unsafe
def
assert_roundtrip
(
filename
):
assert
roundtrip
(
filename
)
==
filename
assert_roundtrip
(
'a b'
)
assert_roundtrip
(
'a b'
)
assert_roundtrip
(
'a b '
)
assert_roundtrip
(
' a b'
)
assert_roundtrip
(
'a
\"
b'
)
assert_roundtrip
(
u'aéio o♥u"qfsdf!'
)
tox.ini
View file @
138f55cd
...
...
@@ -6,5 +6,5 @@ deps=nose
# changedir is a hack to prevent nose from finding the non-2to3 source
# now nose will use import, which has the converted modules in its path
changedir
=
.tox
commands
=
nosetests --detailed-errors rfc6266
commands
=
nosetests --detailed-errors
test_
rfc6266
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