MCPcopy Create free account
hub / github.com/Pylons/webtest / test_multiple_file

Method test_multiple_file

tests/test_forms.py:1101–1127  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1099 "<p>with contents: ''</p>")
1100
1101 def test_multiple_file(self):
1102 uploaded_file_name_1 = os.path.join(os.path.dirname(__file__),
1103 "__init__.py")
1104 uploaded_file_contents_1 = open(uploaded_file_name_1).read()
1105 uploaded_file_contents_1 = to_bytes(uploaded_file_contents_1)
1106
1107 uploaded_file_name_2 = os.path.join(os.path.dirname(__file__),
1108 os.path.basename(__file__))
1109 uploaded_file_contents_2 = open(uploaded_file_name_1).read()
1110 uploaded_file_contents_2 = to_bytes(uploaded_file_contents_2)
1111
1112 app = webtest.TestApp(MultipleUploadFileApp())
1113 res = app.get('/')
1114 self.assertEqual(res.status_int, 200)
1115 self.assertEqual(res.headers['content-type'],
1116 'text/html; charset=utf-8')
1117 self.assertEqual(res.content_type, 'text/html')
1118
1119 single_form = res.forms["file_upload_form"]
1120 single_form.set("files-field", [
1121 (uploaded_file_name_1, uploaded_file_contents_1),
1122 (uploaded_file_name_2, uploaded_file_contents_2),
1123 ])
1124
1125 display = single_form.submit("button")
1126 self.assertFile(uploaded_file_name_1, uploaded_file_contents_1, display)
1127 self.assertFile(uploaded_file_name_2, uploaded_file_contents_2, display)

Callers

nothing calls this directly

Calls 7

getMethod · 0.95
assertFileMethod · 0.95
to_bytesFunction · 0.90
readMethod · 0.80
setMethod · 0.80
submitMethod · 0.80

Tested by

no test coverage detected