fix minitwit/flaskr test errors, improve docs about file open mode

app.open_resource needs to get called with the correct mode param (python3
will read bytes [not str] if the wrong mode is used), add mode param docs.

rv.data is bytes, fix the data type we compare it with to be also bytes
This commit is contained in:
Thomas Waldmann 2013-05-25 19:13:48 +02:00
parent 85ba8c96e9
commit 8bb972e5ae
8 changed files with 42 additions and 40 deletions

View file

@ -630,6 +630,7 @@ class Flask(_PackageBoundObject):
:param resource: the name of the resource. To access resources within
subfolders use forward slashes as separator.
:param mode: resource file opening mode, default is 'rb'.
"""
return open(os.path.join(self.instance_path, resource), mode)

View file

@ -838,6 +838,7 @@ class _PackageBoundObject(object):
:param resource: the name of the resource. To access resources within
subfolders use forward slashes as separator.
:param mode: resource file opening mode, default is 'rb'.
"""
if mode not in ('r', 'rb'):
raise ValueError('Resources can only be opened for reading')