1. Ian Bicking
  2. WebTest
  3. Issues
Issue #31 resolved

order of POST parameters not preserved

Tom Lazar
created an issue

Apparently, webtest does not preserve the order of POST parameters. This is problematic when the application relies on the order, such as is the case when using the deform form library, which inserts hidden fields as markers for (de-)serialization.

in particular, the fact that webtest requires file uploads to be posted separately from the other parameters makes it impossible to test a form containing a deform file upload widget.

Is this an issue you would be willing to address?

Comments (5)

  1. Kai Lautaportti

    I bumped into this very issue today while writing tests for a Pyramid application which uses Deform (and ultimately peppercorn).

    Quick hacking allowed me to get past it by replacing the "fields" dict in ``webtest.app.Form._parse_fields()`` with an instance of ``collections.OrderedDict``. However, this apparently does not help with the file uploads as Tom reports.

    This severely reduces WebTest's usefulness in testing these kinds of applications.

  2. Gael Pasgrimaud
    • changed status to open

    Form now use OrderedDict if available (python>= 2.7).

    The file upload stuff is more tricky.. I keep this issue open and will try to improve the way uploads are handle later. (of course patches are welcome)

  3. Anonymous

    I think a backwards compatible patch is not feasible. I overwrite the _gen_request and encode_multipart methods of TestApp, to handle only params passed as lists of tuples and use the length of the tuples to distinguish between file uploads (len==3) and other parameters (len==2). Unfortunately this rules out using _get_file_info, and imposes a restriction on the way params can be passed.

  4. Log in to comment