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


Python pytest_bdd.scenarios函数代码示例

本文整理汇总了Python中pytest_bdd.scenarios函数的典型用法代码示例。如果您正苦于以下问题:Python scenarios函数的具体用法?Python scenarios怎么用?Python scenarios使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了scenarios函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: declare_scenario

 def declare_scenario():
     if multiple:
         scenarios(feature)
     else:
         @scenario(feature, scenario_name)
         def test_scenario():
             pass
开发者ID:whoislp,项目名称:pytest-bdd,代码行数:7,代码来源:test_wrong.py

示例2: _get_scroll_values

#
# qutebrowser is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser.  If not, see <http://www.gnu.org/licenses/>.

import pytest_bdd as bdd
bdd.scenarios('scroll.feature')


def _get_scroll_values(quteproc):
    data = quteproc.get_session()
    pos = data['windows'][0]['tabs'][0]['history'][0]['scroll-pos']
    return (pos['x'], pos['y'])


@bdd.then(bdd.parsers.re(r"the page should be scrolled "
                         r"(?P<direction>horizontally|vertically)"))
def check_scrolled(quteproc, direction):
    x, y = _get_scroll_values(quteproc)
    if direction == 'horizontally':
        assert x != 0
        assert y == 0
开发者ID:AdaJass,项目名称:qutebrowser,代码行数:31,代码来源:test_scroll.py

示例3: Bruhin

# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:

# Copyright 2015-2017 Florian Bruhin (The Compiler) <[email protected]>
#
# This file is part of qutebrowser.
#
# qutebrowser is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser.  If not, see <http://www.gnu.org/licenses/>.

import pytest_bdd as bdd
bdd.scenarios('misc.feature')


@bdd.then(bdd.parsers.parse('the PDF {filename} should exist in the tmpdir'))
def pdf_exists(quteproc, tmpdir, filename):
    path = tmpdir / filename
    data = path.read_binary()
    assert data.startswith(b'%PDF')
开发者ID:swalladge,项目名称:qutebrowser,代码行数:28,代码来源:test_misc_bdd.py

示例4: check_history

# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser.  If not, see <http://www.gnu.org/licenses/>.

import os.path

import pytest_bdd as bdd
bdd.scenarios('history.feature')


@bdd.then(bdd.parsers.parse("the history file should contain:\n{expected}"))
def check_history(quteproc, httpbin, expected):
    history_file = os.path.join(quteproc.basedir, 'data', 'history')
    quteproc.send_cmd(':save history')
    quteproc.wait_for(message=':save saved history')

    expected = expected.replace('(port)', str(httpbin.port)).splitlines()

    with open(history_file, 'r', encoding='utf-8') as f:
        lines = []
        for line in f:
            if not line.strip():
                continue
开发者ID:Dietr1ch,项目名称:qutebrowser,代码行数:31,代码来源:test_history_bdd.py

示例5: set_up_editor_replacement

# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser.  If not, see <http://www.gnu.org/licenses/>.

import sys
import textwrap

import pytest_bdd as bdd
bdd.scenarios('editor.feature')


@bdd.when(bdd.parsers.parse('I set up a fake editor replacing "{text}" by '
                            '"{replacement}"'))
def set_up_editor_replacement(quteproc, httpbin, tmpdir, text, replacement):
    """Set up general->editor to a small python script doing a replacement."""
    text = text.replace('(port)', str(httpbin.port))
    script = tmpdir / 'script.py'
    script.write(textwrap.dedent("""
        import sys

        with open(sys.argv[1], encoding='utf-8') as f:
            data = f.read()

        data = data.replace("{text}", "{replacement}")
开发者ID:michaelbeaumont,项目名称:qutebrowser,代码行数:31,代码来源:test_editor_bdd.py

示例6: Bruhin

# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:

# Copyright 2015-2017 Florian Bruhin (The Compiler) <[email protected]>
#
# This file is part of qutebrowser.
#
# qutebrowser is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser.  If not, see <http://www.gnu.org/licenses/>.

import pytest_bdd as bdd
bdd.scenarios('backforward.feature')
开发者ID:blyxxyz,项目名称:qutebrowser,代码行数:21,代码来源:test_backforward_bdd.py

示例7: Bruhin

# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:

# Copyright 2015-2016 Florian Bruhin (The Compiler) <[email protected]>
#
# This file is part of qutebrowser.
#
# qutebrowser is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser.  If not, see <http://www.gnu.org/licenses/>.

import pytest_bdd as bdd
bdd.scenarios('zoom.feature')


@bdd.then(bdd.parsers.parse("the zoom should be {zoom}%"))
def check_zoom(quteproc, zoom):
    data = quteproc.get_session()
    value = data['windows'][0]['tabs'][0]['history'][0]['zoom'] * 100
    assert abs(value - float(zoom)) < 0.0001
开发者ID:AdaJass,项目名称:qutebrowser,代码行数:28,代码来源:test_zoom.py

示例8: import

import pytest
from pytest_bdd import (
    scenarios,
    then,
    when,
)
from . import browsersteps

pytestmark = [
    pytest.mark.bdd,
    pytest.mark.usefixtures('workbook'),
]

scenarios('generics.feature')


# https://github.com/pytest-dev/pytest-bdd/issues/124


@when('I visit "/<type_name>/"')
def i_visit_the_collection_for_type_name(browser, base_url, type_name):
    url = '/{}/'.format(type_name)
    browsersteps.when_i_visit_url(browser, base_url, url)


@when('I click the link with text that contains "<link_text>"')
def click_link_with_text_that_contains_link_text(browser, link_text):
    browsersteps.click_link_with_text_that_contains(browser, link_text)


@then('I should see an element with the css selector ".view-item.type-<type_name>"')
开发者ID:ENCODE-DCC,项目名称:encoded,代码行数:31,代码来源:test_generics.py

示例9: scenarios

from __future__ import division
import ast
import math
# pytest is required as an extras_require:
# noinspection PyPackageRequirements
import pytest
from pytest_bdd import parsers
from pytest_bdd import given, when, then, scenarios
from boofuzz import helpers
from boofuzz import ip_constants


scenarios('helpers_udp_checksum.feature')


@given('Empty msg')
def msg_empty(context):
    context.msg = b''


@given(parsers.cfparse('msg {msg}'))
def msg_1_byte(context, msg):
    context.msg = ast.literal_eval(msg)


@given('msg with 60 bytes')
def msg_60_bytes(context):
    # Use each bit at least once...
    all_16_bits = b'\x00\x01\x00\x02\x00\x04\x00\x08\x00\x10\x00\x20\x00\x40\x00\x80' + \
                  b'\x01\x00\x02\x00\x04\x00\x08\x00\x10\x00\x20\x00\x40\x00\x80\x00'
    # Then fill the remaining bytes.
开发者ID:ConcurAppSec,项目名称:boofuzz,代码行数:31,代码来源:test_helpers_udp_checksum.py

示例10: scenarios

from ldap3.core import exceptions
import pytest
from pytest_bdd import scenarios, when, then, parsers

import tldap.database
from tldap import Q
from tldap.django.models import Counters
from tldap.exceptions import ObjectDoesNotExist
from tests.database import Group

scenarios('groups.feature')


@when(parsers.cfparse('we create a group called {name}'))
def step_create_group(ldap, name):
    """ Test if we can create a group. """
    group = Group({
        'cn': name,
        'gidNumber': 10,
        'memberUid': [],
    })
    tldap.database.insert(group)


@when(parsers.cfparse('we modify a group called {name}'))
def step_modify_group(ldap, name):
    """ Test if we can modify a group. """
    group = tldap.database.get_one(Group, Q(cn=name))
    changes = tldap.database.changeset(group, {'gidNumber': 11})
    tldap.database.save(changes)
    group = tldap.database.get_one(Group, Q(cn=name))
开发者ID:Karaage-Cluster,项目名称:python-tldap,代码行数:31,代码来源:test_groups.py

示例11: scenarios

import pytest
import six
from pytest_bdd import parsers, scenarios, then, when

from spud import models


scenarios('persons.feature')


@when('we create a person called <name>')
def step_create_person(session, name):
    url = "/api/persons/"
    data = {
        'first_name': name,
        'cover_photo_pk': None,
        'notes': 'notes',
    }
    session.post(url, json=data)


@when('we update a person called <name>')
def step_update_person(session, persons, name):
    desired_person = models.person.objects.get(first_name=name)
    url = "/api/persons/%d/" % desired_person.id
    data = {
        'first_name': name,
        'cover_photo_pk': None,
        'notes': 'new notes',
    }
    session.put(url, json=data)
开发者ID:brianmay,项目名称:spud,代码行数:31,代码来源:test_persons.py

示例12: check_found_text

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser.  If not, see <http://www.gnu.org/licenses/>.

import json

import pytest_bdd as bdd

# pylint: disable=unused-import
from end2end.features.test_yankpaste_bdd import init_fake_clipboard
# pylint: enable=unused-import


@bdd.then(bdd.parsers.parse('"{text}" should be found'))
def check_found_text(request, quteproc, text):
    if request.config.webengine:
        # WORKAROUND
        # This probably should work with Qt 5.9:
        # https://codereview.qt-project.org/#/c/192920/
        # https://codereview.qt-project.org/#/c/192921/
        # https://bugreports.qt.io/browse/QTBUG-53134
        return
    quteproc.send_cmd(':yank selection')
    quteproc.wait_for(message='Setting fake clipboard: {}'.format(
        json.dumps(text)))


bdd.scenarios('search.feature')
开发者ID:The-Compiler,项目名称:qutebrowser,代码行数:30,代码来源:test_search_bdd.py

示例13: Bruhin

# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:

# Copyright 2015-2016 Florian Bruhin (The Compiler) <[email protected]>
#
# This file is part of qutebrowser.
#
# qutebrowser is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser.  If not, see <http://www.gnu.org/licenses/>.

import pytest_bdd as bdd
bdd.scenarios('set.feature')


@bdd.then(bdd.parsers.parse("{section} -> {option} should be {value}"))
def check_option(quteproc, section, option, value):
    actual_value = quteproc.get_setting(section, option)
    assert actual_value == value
开发者ID:AdaJass,项目名称:qutebrowser,代码行数:27,代码来源:test_set.py

示例14:

# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:

# Copyright 2016 Ryan Roden-Corrent (rcorre) <[email protected]>
#
# This file is part of qutebrowser.
#
# qutebrowser is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser.  If not, see <http://www.gnu.org/licenses/>.

import pytest_bdd as bdd

bdd.scenarios("completion.feature")
开发者ID:lahwaacz,项目名称:qutebrowser,代码行数:22,代码来源:test_completion_bdd.py

示例15: temporary_download_dir

# qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser.  If not, see <http://www.gnu.org/licenses/>.

import os
import sys
import shlex

import pytest
import pytest_bdd as bdd
from PyQt5.QtNetwork import QSslSocket
bdd.scenarios('downloads.feature')


PROMPT_MSG = ("Asking question <qutebrowser.utils.usertypes.Question "
              "default={!r} mode=<PromptMode.download: 5> text=* "
              "title='Save file to:'>, *")


@bdd.given("I set up a temporary download dir")
def temporary_download_dir(quteproc, tmpdir):
    download_dir = tmpdir / 'downloads'
    download_dir.ensure(dir=True)
    quteproc.set_setting('downloads.location.prompt', 'false')
    quteproc.set_setting('downloads.location.remember', 'false')
    quteproc.set_setting('downloads.location.directory', str(download_dir))
    (download_dir / 'subdir').ensure(dir=True)
开发者ID:The-Compiler,项目名称:qutebrowser,代码行数:31,代码来源:test_downloads_bdd.py


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