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

Method get_files_page

tests/test_forms.py:847–862  ·  view source on GitHub ↗
(self, req)

Source from the content-addressed store, hash-verified

845 return [body]
846
847 def get_files_page(self, req):
848 file_parts = []
849 uploaded_files = [(k, v) for k, v in req.POST.items() if 'file' in k]
850 for name, uploaded_file in uploaded_files:
851 if isinstance(uploaded_file, cgi.FieldStorage):
852 filename = to_bytes(uploaded_file.filename)
853 value = to_bytes(uploaded_file.value, 'ascii')
854 content_type = to_bytes(uploaded_file.type, 'ascii')
855 else:
856 filename = value = content_type = b''
857 file_parts.append(b"""
858 <p>You selected '""" + filename + b"""'</p>
859 <p>with contents: '""" + value + b"""'</p>
860 <p>with content type: '""" + content_type + b"""'</p>
861""")
862 return b''.join(file_parts)
863
864
865class UploadBinaryApp(SingleUploadFileApp):

Callers 1

__call__Method · 0.95

Calls 2

to_bytesFunction · 0.90
itemsMethod · 0.80

Tested by

no test coverage detected