Skip to content

Commit

Permalink
test_parse_form: test FileIO
Browse files Browse the repository at this point in the history
  • Loading branch information
yecril23pl authored Feb 29, 2024
1 parent e47d869 commit 70d8a27
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,16 @@ def test_parse_form(self):
with open ('12345678.txt', 'wt+') as f:
f .write ('123456789012345')
f .seek (0o0)
parse_form({"Content-Type": "application/octet-stream"}, f .buffer, on_field, on_file)

assert on_file.call_count == 1

# Assert that the first argument of the call (a File object) has size
# 15 - i.e. all data is written.
self.assertEqual(on_file.call_args[0][0].size, 15)

with open ('12345678.txt', 'r') as f:
self .assertTrue (isinstance (f, type (sys .stdin)))
parse_form({"Content-Type": "application/octet-stream"}, f, on_field, on_file)

assert on_file.call_count == 1
Expand Down

0 comments on commit 70d8a27

Please sign in to comment.