I attempted to solve this by inserting data into the request environment, including the form name, however I did not have any luck..
I would use WebTest for file upload testing instead, however you will need to use a mixture of webtest and new_env(), this is because you need to get the unique _formkey variable so that web2py can validate properly. http://pythonpaste.org/webtest/#making-requests I am thinking of some sample pseudocode below. env = new_env(app='test_upload', controller='default') res = env['upload_a_file']() req = {} for hidden in form.custom.end.elements(): try: if hidden.has_key('_name') and hidden.has_key('_value'): req[hidden['_name']] = hidden['_value'] except AttributeError: pass req['name'] = 'ABOUT.txt' Then continue and use the uploaded_files list in webtest and perform an app.post(....) on the function. Now you can verify using another new_env that the record was inserted, and you can manually check the existence of the file and its contents. -- Thadeus On Sat, May 15, 2010 at 12:58 PM, Mathieu Clabaut <[email protected]> wrote: > Hello, > I'd like to test an upload function in my default controller (I use > Thadeus testrunner from web2py_utils). > I wonder what object I shall put in my request.post_vars.file where 'file' > is the upload field ? > Apparently it should have a 'filename' attribute and a read method ? > Any tip on how to populate the request for such an upload form ? > -Mathieu

