Pylons/webtest — pull request #82 by carljm (2013-08-31 02:08:29+00:00)
Title: Convenience API for setting multiple checkboxes by value

In my web forms it is fairly common to represent what is conceptually a "select multiple" via multiple checkboxes all with the same name, with different values. (Django even has a form widget, `CheckboxSelectMultiple`, to encapsulate this pattern).

With WebTest it's possible to set these checkboxes using `form.set('name', index=3)`, but this is a bit painful, since usually in my test I know and care about the value of each checkbox, not its ordering on the page. So I frequently end up doing this:

```
for field in form.fields['grades']:
field.checked = field._value in {'3', '4'}:
```

This works, but it relies on internal API (`field._value`) and the intent isn't as clear as it could be. Really what I'm trying to say is "I want the list [3, 4] to be the submitted value for the name 'grades'", but WebTest won't let me say that directly.

Would you be open to a convenience API for this purpose? Something like `form.set_checkboxes('grades', ['3', '4'])`. If so, I will do the implementation.