Skip to content

Commit

Permalink
Merge pull request #261 from hemberger/fix-link-tests
Browse files Browse the repository at this point in the history
Improve `test_link_arg_*` tests
  • Loading branch information
hemberger committed Jan 18, 2019
2 parents cfbfb75 + 2e00517 commit 3c7a4fb
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/test_stateful_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,18 +421,18 @@ def test_referer_submit_headers(httpbin):
assert headers['X-Test-Header'] == 'x-test-value'


def test_link_arg_text(httpbin):
browser = mechanicalsoup.StatefulBrowser()
browser.open_fake_page('<a href="/get">Link</a>', httpbin.url)
browser.follow_link(link_text='Link')
assert browser.get_url() == httpbin + '/get'


def test_link_arg_regex(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),
])
def test_follow_link_arg(httpbin, expected, kwargs):
browser = mechanicalsoup.StatefulBrowser()
browser.open_fake_page('<a href="/get">Link</a>', httpbin.url)
browser.follow_link(url_regex='.*')
assert browser.get_url() == httpbin + '/get'
html = '<a href="/foo">Bar</a><a href="/get">Link</a>'
browser.open_fake_page(html, httpbin.url)
browser.follow_link(**kwargs)
assert browser.get_url() == httpbin + expected


def test_link_arg_multiregex(httpbin):
Expand Down

0 comments on commit 3c7a4fb

Please sign in to comment.