Skip to content

Commit

Permalink
test_form.py: fix test_choose_submit_twice
Browse files Browse the repository at this point in the history
When a BeautifulSoup object is constructed from an html string,
it will standardize the html. In this case, since the input html
was just a raw <form>, it added <html> and <body> tags around it.

Since the `Form` ctor now demands that it is passed a <form> element,
we need to extract <form> from the object BeautifulSoup constructs
to pass to the `Form` ctor.
  • Loading branch information
hemberger committed Aug 22, 2018
1 parent 7b0f114 commit 730ca4a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/test_form.py
Expand Up @@ -156,7 +156,8 @@ def test_choose_submit_twice():
<input type="submit" name="test2" value="Test2" />
</form>
'''
form = mechanicalsoup.Form(bs4.BeautifulSoup(text, 'lxml'))
soup = bs4.BeautifulSoup(text, 'lxml')
form = mechanicalsoup.Form(soup.form)
form.choose_submit('test1')
expected_msg = 'Submit already chosen. Cannot change submit!'
with pytest.raises(Exception, match=expected_msg):
Expand Down

0 comments on commit 730ca4a

Please sign in to comment.