当前位置: 首页>>代码示例>>Python>>正文


Python pytest_bdd.given方法代码示例

本文整理汇总了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) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:5,代码来源:conftest.py

示例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 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:13,代码来源:conftest.py

示例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) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:6,代码来源:conftest.py

示例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)) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:5,代码来源:conftest.py

示例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) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:5,代码来源:conftest.py

示例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) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:9,代码来源:conftest.py

示例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) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:5,代码来源:conftest.py

示例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 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:8,代码来源:conftest.py

示例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)) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:12,代码来源:conftest.py

示例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) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:13,代码来源:conftest.py

示例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) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:5,代码来源:conftest.py

示例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) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:5,代码来源:conftest.py

示例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)) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:6,代码来源:conftest.py

示例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) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:9,代码来源:conftest.py

示例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) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:15,代码来源:conftest.py


注:本文中的pytest_bdd.given方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。