fix test_view_urlencoded
This commit is contained in:
parent
9b40e1072c
commit
61de6fa1d6
|
@ -109,12 +109,16 @@ class View(object):
|
|||
prompt = ()
|
||||
content_types = []
|
||||
|
||||
def __call__(self, data, **metadata):
|
||||
def __call__(
|
||||
self,
|
||||
data, # type: bytes
|
||||
**metadata
|
||||
):
|
||||
"""
|
||||
Transform raw data into human-readable output.
|
||||
|
||||
Args:
|
||||
data: the data to decode/format as bytes.
|
||||
data: the data to decode/format.
|
||||
metadata: optional keyword-only arguments for metadata. Implementations must not
|
||||
rely on a given argument being present.
|
||||
|
||||
|
@ -282,7 +286,7 @@ class ViewURLEncoded(View):
|
|||
|
||||
def __call__(self, data, **metadata):
|
||||
try:
|
||||
data = data.decode("ascii","strict")
|
||||
data = data.decode("ascii", "strict")
|
||||
except ValueError:
|
||||
return None
|
||||
d = url.decode(data)
|
||||
|
|
|
@ -82,6 +82,7 @@ def unparse(scheme, host, port, path=""):
|
|||
|
||||
|
||||
def encode(s):
|
||||
# type: (six.text_type, bytes) -> str
|
||||
"""
|
||||
Takes a list of (key, value) tuples and returns a urlencoded string.
|
||||
"""
|
||||
|
|
|
@ -59,10 +59,10 @@ class TestContentView:
|
|||
assert f[0] == "Query"
|
||||
|
||||
def test_view_urlencoded(self):
|
||||
d = url.encode([("one", "two"), ("three", "four")])
|
||||
d = url.encode([("one", "two"), ("three", "four")]).encode()
|
||||
v = cv.ViewURLEncoded()
|
||||
assert v(d)
|
||||
d = url.encode([("adsfa", "")])
|
||||
d = url.encode([("adsfa", "")]).encode()
|
||||
v = cv.ViewURLEncoded()
|
||||
assert v(d)
|
||||
|
||||
|
|
Loading…
Reference in New Issue