Skip to content

Commit

Permalink
debug _find_link_internal and remove xfail on related test
Browse files Browse the repository at this point in the history
If you called the function with url_regex='/something' and not the
link argument, it would set the url_regex to None, and thus the result
would be impredictable.

This is tested by the test added by #261
  • Loading branch information
Thibault Roche authored and moy committed Mar 1, 2019
1 parent 995d1a4 commit d3e1cde
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mechanicalsoup/stateful_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def _find_link_internal(self, link, args, kwargs):
raise ValueError('link parameter cannot be treated as '
'url_regex because url_regex is already '
'present in keyword arguments')
else:
elif link:
kwargs['url_regex'] = link

try:
Expand Down
3 changes: 1 addition & 2 deletions tests/test_stateful_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,7 @@ def test_referer_submit_headers(httpbin):
@pytest.mark.parametrize('expected, kwargs', [
pytest.param('/foo', {}, id='none'),
pytest.param('/get', {'text': 'Link'}, id='text'),
pytest.param('/get', {'url_regex': 'get'}, id='regex',
marks=pytest.mark.xfail),
pytest.param('/get', {'url_regex': 'get'}, id='regex'),
])
def test_follow_link_arg(httpbin, expected, kwargs):
browser = mechanicalsoup.StatefulBrowser()
Expand Down

0 comments on commit d3e1cde

Please sign in to comment.