Pylons / Pylons/webtest

form.submit should verify it's possible to submit the form

Open
#134 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
346
Forks
113
PR merge metrics
No merged PRs in 30d

Description

I was surprised to learn today that I had made a form which was impossible to submit. I had used webtest to verify that the form was submittable by calling the "form.submit()" method.

If the button referenced in submit() doesn't exist, or if it doesn't actually submit the form, an error should be raised.

For example, this test could be added to tests/test_forms.py:

    def test_incorrect_button_name(self):
        form = self.callFUT(formid='multiple_buttons_form')
        with self.assertRaises(ValueError):
            form.submit("button_that_does_not_exist")

Then another test is needed where the button exists, but doesn't actually submit the form.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tests/test_forms.py and the existing form.submit behavior. Add coverage for a missing button and for a button that does not submit the form, then verify both cases raise ValueError and the existing form tests still pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.