diff options
| author | Marius Gedminas <marius@gedmin.as> | 2013-09-16 18:06:08 +0300 |
|---|---|---|
| committer | Marius Gedminas <marius@gedmin.as> | 2013-09-16 18:06:08 +0300 |
| commit | e19f3b9d8876736aff0550792a3fba461ea42155 (patch) | |
| tree | a70c4f2d531798a819c39478db78efb6c26a865c /webtest/forms.py | |
| parent | d4dbc677d8cfaa48070371a662b9bde29b6ed8be (diff) | |
| download | webtest-e19f3b9d8876736aff0550792a3fba461ea42155.tar.gz | |
Allow specifying the MIME type of an uploaded file
Fixes #86
Diffstat (limited to 'webtest/forms.py')
| -rw-r--r-- | webtest/forms.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/webtest/forms.py b/webtest/forms.py index 8875dd3..c30fdf6 100644 --- a/webtest/forms.py +++ b/webtest/forms.py @@ -16,6 +16,8 @@ class Upload(object): """ A file to upload:: + >>> Upload('filename.txt', 'data', 'application/octet-stream') + <Upload "filename.txt"> >>> Upload('filename.txt', 'data') <Upload "filename.txt"> >>> Upload("README.txt") @@ -23,17 +25,20 @@ class Upload(object): :param filename: Name of the file to upload. :param content: Contents of the file. + :param content_type: MIME type of the file. """ - def __init__(self, filename, content=None): + def __init__(self, filename, content=None, content_type=None): self.filename = filename self.content = content + self.content_type = content_type def __iter__(self): yield self.filename if self.content: yield self.content + # XXX: do we need to yield self.content_type here? # TODO: do we handle the case when we need to get # contents ourselves? |
