Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test_link_arg_* tests #261

Merged
merged 1 commit into from
Jan 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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