Skip to content

Commit

Permalink
Revert "Always convert an uploaded file to a string, don't pass files…
Browse files Browse the repository at this point in the history
… just because they're real files."

This reverts commit 578f41a.
  • Loading branch information
MatthewWilkes committed Feb 2, 2017
1 parent 29d15e4 commit f6f605c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 0 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ CHANGES
- Fixed browser to only follow redirects for HTTP statuses
301, 302, 303, and 307; not other 30x statuses such as 304.

- Fix passing a real file to ``add_file``.


5.1 (2017-01-31)
----------------
Expand Down
6 changes: 5 additions & 1 deletion src/zope/testbrowser/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,11 @@ def add_file(self, file, content_type, filename):
raise TypeError("Can't call add_file on %s controls"
% self.mech_control.type)

contents = file.read()
if isinstance(file, io.IOBase):
contents = file.read()
else:
contents = file

self._form[self.name] = webtest.forms.Upload(filename or '', contents,
content_type)

Expand Down

0 comments on commit f6f605c

Please sign in to comment.