diff options
| author | Gael Pasgrimaud <gael@gawel.org> | 2013-01-28 16:00:28 +0100 |
|---|---|---|
| committer | Gael Pasgrimaud <gael@gawel.org> | 2013-01-28 16:00:28 +0100 |
| commit | d5cff51fd1ce4ceb0ccbff4e84f46bcb63582bdc (patch) | |
| tree | 5d59e046bcdf4c16147b6991d1be06e87eb06036 /webtest/forms.py | |
| parent | 6f5a2a2ddd18f95cb1c65958a37fd116051b85aa (diff) | |
| download | webtest-d5cff51fd1ce4ceb0ccbff4e84f46bcb63582bdc.tar.gz | |
improve and add doc for Upload
Diffstat (limited to 'webtest/forms.py')
| -rw-r--r-- | webtest/forms.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/webtest/forms.py b/webtest/forms.py index bf0e52d..d1b08ae 100644 --- a/webtest/forms.py +++ b/webtest/forms.py @@ -3,7 +3,6 @@ __doc__ = """Helpers to fill and submit forms""" from webtest.compat import OrderedDict from webtest import utils import re -import os class Upload(object): @@ -11,17 +10,17 @@ class Upload(object): >>> Upload('filename.txt', 'data') <Upload "filename.txt"> - >>> Upload(__file__) - <Upload "forms.py"> + >>> Upload("README.txt") + <Upload "README.txt"> """ def __init__(self, filename, content=None): self.filename = filename self.content = content - if content is None and os.path.isfile(filename): - self.filename = os.path.basename(filename) - fd = open(filename, 'rb') - self.content = fd.read() - fd.close() + + def __iter__(self): + yield self.filename + if self.content: + yield self.content def __repr__(self): return '<Upload "%s">' % self.filename |
