本文整理匯總了Python中pytest_bdd.given方法的典型用法代碼示例。如果您正苦於以下問題:Python pytest_bdd.given方法的具體用法?Python pytest_bdd.given怎麽用?Python pytest_bdd.given使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pytest_bdd
的用法示例。
在下文中一共展示了pytest_bdd.given方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: wait_until_loaded
# 需要導入模塊: import pytest_bdd [as 別名]
# 或者: from pytest_bdd import given [as 別名]
def wait_until_loaded(quteproc, path):
"""Wait until the given path is loaded (as per qutebrowser log)."""
quteproc.wait_for_load_finished(path)
示例2: wait_in_log
# 需要導入模塊: import pytest_bdd [as 別名]
# 或者: from pytest_bdd import given [as 別名]
def wait_in_log(quteproc, is_regex, pattern, do_skip):
"""Wait for a given pattern in the qutebrowser log.
If used like "When I wait for regex ... in the log" the argument is treated
as regex. Otherwise, it's treated as a pattern (* can be used as wildcard).
"""
if is_regex:
pattern = re.compile(pattern)
line = quteproc.wait_for(message=pattern, do_skip=bool(do_skip))
line.expected = True
示例3: wait_for_message
# 需要導入模塊: import pytest_bdd [as 別名]
# 或者: from pytest_bdd import given [as 別名]
def wait_for_message(quteproc, server, category, message):
"""Wait for a given statusbar message/error/warning."""
quteproc.log_summary('Waiting for {} "{}"'.format(category, message))
expect_message(quteproc, server, category, message)
示例4: wait_time
# 需要導入模塊: import pytest_bdd [as 別名]
# 或者: from pytest_bdd import given [as 別名]
def wait_time(quteproc, delay):
"""Sleep for the given delay."""
time.sleep(float(delay))
示例5: press_keys
# 需要導入模塊: import pytest_bdd [as 別名]
# 或者: from pytest_bdd import given [as 別名]
def press_keys(quteproc, keys):
"""Send the given fake keys to qutebrowser."""
quteproc.press_keys(keys)
示例6: path_should_be_loaded
# 需要導入模塊: import pytest_bdd [as 別名]
# 或者: from pytest_bdd import given [as 別名]
def path_should_be_loaded(quteproc, path):
"""Make sure the given path was loaded according to the log.
This is usually the better check compared to "should be requested" as the
page could be loaded from local cache.
"""
quteproc.wait_for_load_finished(path)
示例7: path_should_be_requested
# 需要導入模塊: import pytest_bdd [as 別名]
# 或者: from pytest_bdd import given [as 別名]
def path_should_be_requested(server, path):
"""Make sure the given path was loaded from the webserver."""
server.wait_for(verb='GET', path='/' + path)
示例8: list_of_requests
# 需要導入模塊: import pytest_bdd [as 別名]
# 或者: from pytest_bdd import given [as 別名]
def list_of_requests(server, pages):
"""Make sure the given requests were done from the webserver."""
expected_requests = [server.ExpectedRequest('GET', '/' + path.strip())
for path in pages.split('\n')]
actual_requests = server.get_requests()
assert actual_requests == expected_requests
示例9: list_of_requests_unordered
# 需要導入模塊: import pytest_bdd [as 別名]
# 或者: from pytest_bdd import given [as 別名]
def list_of_requests_unordered(server, pages):
"""Make sure the given requests were done (in no particular order)."""
expected_requests = [server.ExpectedRequest('GET', '/' + path.strip())
for path in pages.split('\n')]
actual_requests = server.get_requests()
# Requests are not hashable, we need to convert to ExpectedRequests
actual_requests = [server.ExpectedRequest.from_request(req)
for req in actual_requests]
assert (collections.Counter(actual_requests) ==
collections.Counter(expected_requests))
示例10: expect_message
# 需要導入模塊: import pytest_bdd [as 別名]
# 或者: from pytest_bdd import given [as 別名]
def expect_message(quteproc, server, category, message):
"""Expect the given message in the qutebrowser log."""
category_to_loglevel = {
'message': logging.INFO,
'error': logging.ERROR,
'warning': logging.WARNING,
}
message = message.replace('(port)', str(server.port))
quteproc.mark_expected(category='message',
loglevel=category_to_loglevel[category],
message=message)
示例11: ensure_not_logged
# 需要導入模塊: import pytest_bdd [as 別名]
# 或者: from pytest_bdd import given [as 別名]
def ensure_not_logged(quteproc, pattern):
"""Make sure the given pattern was *not* logged."""
quteproc.ensure_not_logged(message=pattern)
示例12: javascript_message_logged
# 需要導入模塊: import pytest_bdd [as 別名]
# 或者: from pytest_bdd import given [as 別名]
def javascript_message_logged(quteproc, message):
"""Make sure the given message was logged via javascript."""
quteproc.wait_for_js(message)
示例13: javascript_message_not_logged
# 需要導入模塊: import pytest_bdd [as 別名]
# 或者: from pytest_bdd import given [as 別名]
def javascript_message_not_logged(quteproc, message):
"""Make sure the given message was *not* logged via javascript."""
quteproc.ensure_not_logged(category='js',
message='[*] {}'.format(message))
示例14: compare_session
# 需要導入模塊: import pytest_bdd [as 別名]
# 或者: from pytest_bdd import given [as 別名]
def compare_session(request, quteproc, expected):
"""Compare the current sessions against the given template.
partial_compare is used, which means only the keys/values listed will be
compared.
"""
quteproc.compare_session(expected)
示例15: check_header
# 需要導入模塊: import pytest_bdd [as 別名]
# 或者: from pytest_bdd import given [as 別名]
def check_header(quteproc, header, value):
"""Check if a given header is set correctly.
This assumes we're on the server header page.
"""
content = quteproc.get_content()
data = json.loads(content)
print(data)
if value == '<unset>':
assert header not in data['headers']
else:
actual = data['headers'][header]
assert testutils.pattern_match(pattern=value, value=actual)