def declare_scenario(): if multiple: scenarios(feature) else: @scenario(feature, scenario_name) def test_scenario(): pass
from pytest_bdd import scenario, given, when, then, scenarios, parsers import allure from Pagelocators.adder import * from Pagelocators.update_build import * # from tests.testcase2.step_defs.WebDeiverFactory import * from tests.testcase1.step_defs.WebDeiverFactory import * scenarios('../features/Rx_Tx_UpAndDown.feature') # scenarios('D:\pythonProject\adderCode1\tests\testcase6\features\Rx_Tx_UpAndDown.feature') @given("user is in aim login page or not") def user_is_in_aim_login_page_or_not(): driver.implicitly_wait(30) expected_login_screen = 'AdderLink Infinity Management Suite' actual_login_screen = driver.find_element_by_xpath( '//*[@id="admin_logo_left"]').text # import pdb; pdb.set_trace() if expected_login_screen == actual_login_screen: print("user is in aim login page") assert True allure.attach(driver.get_screenshot_as_png(), name='screenshot', attachment_type=allure.attachment_type.PNG) else: print("user is not is aim login page") allure.attach(driver.get_screenshot_as_png(), name='screenshot', attachment_type=allure.attachment_type.PNG)
# 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
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2015-2017 Florian Bruhin (The Compiler) <*****@*****.**> # # 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')
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>"')
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2015-2016 Florian Bruhin (The Compiler) <*****@*****.**> # # 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('navigate.feature')
from ebu_tt_live.documents import EBUTT3Document from ebu_tt_live.bindings._ebuttdt import FullClockTimingType, LimitedClockTimingType from pytest_bdd import scenarios, then, when, parsers scenarios('features/timing/resolved_times.feature') def timestr_to_timedelta(time_str, time_base): if time_base == 'clock': return LimitedClockTimingType(time_str).timedelta elif time_base == 'media': return FullClockTimingType(time_str).timedelta elif time_base == 'smpte': raise NotImplementedError('SMPTE needs implementation') @when('we create a new document') def when_new_doc(template_dict): template_dict.clear() @when('it has timeBase <time_base>') def when_time_base(time_base, template_dict): template_dict['time_base'] = time_base @when('it has sequenceIdentifier <sequence_identifier>') def when_seq_id(sequence_identifier, template_dict): template_dict['sequence_identifier'] = sequence_identifier
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2015-2017 Florian Bruhin (The Compiler) <*****@*****.**> # # 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('spawn.feature')
from pytest_bdd import scenarios scenarios( 'features/application_details_api.feature', 'features/applications_list_api.feature', 'features/featured_applications.feature', )
'0.256.0.0', '0.0.256.0', '0.0.0.256', '1.2.3.', '1.2.3.-1', '1.2..3', '1..2.3', '.1.2.3', '']) @scenario('helpers_ip_str_to_bytes.feature', 'Invalid IP addresses') def test_invalid_ip_addresses(bad_ip_str): _ = bad_ip_str pass scenarios('helpers_ip_str_to_bytes.feature') @given("Various IP addresses and expected values") def ips_and_values(context, ip_str, ip_bytes): context.ip = ip_str context.expected = ip_bytes @when("Calling ip_str_to_bytes") def call(context): try: context.result = helpers.ip_str_to_bytes(context.ip) except ValueError as e: context.exc_info = e
from pytest_bdd import scenarios, given scenarios("../features/view_mod_clearance.feature", strict_gherkin=False) @given("a F680 Clearance is created") # noqa def an_f680_clearance_is_created(driver, apply_for_f680_clearance): pass @given("a Gifting Clearance is created") # noqa def an_gifting_clearance_is_created(driver, apply_for_gifting_clearance): pass
"""Component level tests of component B""" # pragma pylint: disable=missing-docstring,redefined-outer-name from ast import literal_eval from pytest_bdd import scenarios, given, when, then, parsers from mysw.b import B scenarios('../features/component_b.feature') @given('new instance of component B') def component_b(): """Given steps works as fixture, it will return a component B for the tests""" return B() @when(parsers.parse('I set the list "{text}"')) def set_text(text, component_b): in_list = literal_eval(text) component_b.set(in_list) @then(parsers.parse('I get the answer "{text}"')) def get_list(text, component_b): expected = literal_eval(text) component_b.proc() assert component_b.get() == expected
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2015-2021 Florian Bruhin (The Compiler) <*****@*****.**> # # 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 <https://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')
import pytest import logging from pytest_bdd import (scenarios, given, then, when, parsers) from google_search import GoogleSearch scenarios('../features/search.feature') @given('User is at Google') def visit_google(config, web_browser, context): google_home = GoogleSearch(web_browser, config) google_home.load() context["browser"] = google_home assert "Google" in google_home.title(), "You are not at Google" @when('User searches desired word') def search_input(context): google_home = context["browser"] google_result = google_home.search_input() context["browser"] = google_result @then('User clicks at first link') def click_on_link(context): google_result = GoogleSearch(*context["browser"]) context["browser"] = google_result.click_on() @then('Is redirected to site')
# vim: ft=python fileencoding=utf-8 sw=4 et sts=4 # This file is part of vimiv. # Copyright 2017-2020 Christian Karl (karlch) <karlch at protonmail dot com> # License: GNU GPL v3, see the "LICENSE" and "AUTHORS" files for details. import pytest_bdd as bdd bdd.scenarios("imagefit.feature") def almost_equal(size, expected): """Check if size is almost equal to the expected value. When scaling images the float value scale times the integer original size can lead to the size being smaller than the expected value by one. """ assert size + 1 >= expected assert size <= expected @bdd.then(bdd.parsers.parse("the pixmap width should be {width}")) def check_pixmap_width(image, width): almost_equal(image.scene().sceneRect().width() * image.zoom_level, int(width)) @bdd.then(bdd.parsers.parse("the pixmap height should be {height}")) def check_pixmap_height(image, height): almost_equal(image.scene().sceneRect().height() * image.zoom_level, int(height))
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2016 Ryan Roden-Corrent (rcorre) <*****@*****.**> # # 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")
# 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')
from pytest_bdd import when, scenarios scenarios('features/validation/sequence_id_num.feature') @when('it has sequence identifier <seq_id>') def when_sequence_id(seq_id, template_dict): template_dict['sequence_id'] = seq_id @when('it has sequence number <seq_n>') def when_sequence_number(seq_n, template_dict): template_dict['sequence_num'] = seq_n
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.
from pytest_bdd import scenario, given, when, then, scenarios, parsers import pytest ''' CALL TESTS FROM FEATURES FOLDER: ''' scenarios('../features/UserTable.feature') ''' STEPS FOR THE FEATURE User Table: spliner style (java analog: selenide) w/o page object ''' @when('I click on "User Table" button in Service dropdown') def go_to_user_table(driver): driver.find_by_css('.dropdown-toggle').click() driver.click_link_by_text("User Table ") @then('"User Table" page is opened') def check_the_page_is_user_table(driver): assert driver.url == 'https://epam.github.io/JDI/user-table.html' @then('<dropdown> NumberType Dropdowns are displayed on Users Table on User Table Page') def dropdowns_count(driver, dropdown): list_of_checkbox = driver.find_by_tag('select') assert len(list_of_checkbox) == int(dropdown)
# # 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 from helpers import utils bdd.scenarios('urlmarks.feature') def _check_marks(quteproc, quickmarks, expected, contains): """Make sure the given line does (not) exist in the bookmarks. Args: quickmarks: True to check the quickmarks file instead of bookmarks. expected: The line to search for. contains: True if the line should be there, False otherwise. """ if quickmarks: mark_file = os.path.join(quteproc.basedir, 'config', 'quickmarks') else: mark_file = os.path.join(quteproc.basedir, 'config', 'bookmarks', 'urls')
import requests from pytest_bdd import given from pytest_bdd import parsers from pytest_bdd import scenarios from pytest_bdd import then # Shared Variables from config import DUCKDUCKGO_API # Scenarios scenarios("../features/api.feature", example_converters=dict(phrase=str)) # Given Steps @given('the DuckDuckGo API is queried with "<phrase>"', target_fixture="ddg_response") def ddg_response(phrase): params = {"q": phrase, "format": "json"} response = requests.get(f"{DUCKDUCKGO_API}", params=params) return response # Then Steps @then('the response contains results for "<phrase>"') def ddg_response_contents(ddg_response, phrase): assert phrase.lower() == ddg_response.json()["Heading"].lower()
# 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)
from pytest_bdd import scenarios, parsers, given, when, then from cucumbers import CucumberBasket EXTRA_TYPES = { 'Number': int, } CONVERTERS = { 'initial': int, 'some': int, 'total': int, } scenarios('../features/cucumbers.feature', example_converters=CONVERTERS) @given(parsers.cfparse('the basket has "{initial:Number}" cucumbers', extra_types=EXTRA_TYPES), target_fixture='basket') @given('the basket has "<initial>" cucumbers', target_fixture='basket') def basket(initial): return CucumberBasket(initial_count=initial) @when( parsers.cfparse('"{some:Number}" cucumbers are added to the basket', extra_types=EXTRA_TYPES)) @when('"<some>" cucumbers are added to the basket') def add_cucumbers(basket, some): basket.add(some)
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2015-2016 Florian Bruhin (The Compiler) <*****@*****.**> # # 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
import pytest from pytest_bdd import scenarios, parsers, given, when, then from selenium import webdriver from selenium.webdriver.common.keys import Keys DUCKDUCKGO_HOME = 'https://duckduckgo.com' scenarios('../features/web.feature') @pytest.fixture def browser(): b = webdriver.Firefox() b.implicitly_wait(10) yield b b.quit() # Given steps @given('the DuckDuckGo home page is displayed') def ddg_home(browser): browser.get(DUCKDUCKGO_HOME) # When steps
# 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}")
from pages.application_page import ApplicationPage from pages.case_list_page import CaseListPage from pages.open_general_licences_pages import ( OpenGeneralLicencesListPage, OpenGeneralLicencesCreateEditPage, OpenGeneralLicencesDetailPage, OpenGeneralLicencesDeactivatePage, OpenGeneralLicencesCasePage, ) from shared import functions from ui_automation_tests.pages.case_page import CasePage, CaseTabs from ui_automation_tests.pages.shared import Shared scenarios("../features/open_general_licences.feature", strict_gherkin=False) fake = Faker() @when("I go to open general licences") def go_to_open_general_licences(driver, internal_url): driver.get(internal_url.rstrip("/") + "/open-general-licences/") @when("I click the new open general licence button") def click_the_open_general_licence_button(driver): OpenGeneralLicencesListPage(driver).click_new_open_general_licence_button() @when("I select Open General Export Licence")
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2015-2017 Florian Bruhin (The Compiler) <*****@*****.**> # # 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')
import pytest import requests import json from pytest_bdd import scenarios, when, then URL = "https://api-football-v1.p.rapidapi.com/v3/players" HEADERS = { 'x-rapidapi-key': "abe8b4c5d8msh9283322f2a4cbc8p1043f7jsnf567d5f51908", 'x-rapidapi-host': "api-football-v1.p.rapidapi.com" } scenarios('../features/get_players.feature') @pytest.fixture() @when('the football api is queried with "<team>" and "<season>"') def get_players(team, season): headers = HEADERS response = requests.get(URL + '?team=' + team + '&season=' + season, headers=headers) return response @then('the response status code is 200') def get_response_code(get_players): assert get_players.status_code == 200 @then('the response shows the "<players>" which are part of the team') def get_players_data(get_players, players): data = get_players.json() players_data = {} players = players.replace("\'", "\"") players = json.loads(players)
# # 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
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2016-2020 Florian Bruhin (The Compiler) <*****@*****.**> # # 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 import pytest_bdd as bdd bdd.scenarios('utilcmds.feature') @pytest.fixture(autouse=True) def turn_on_scroll_logging(quteproc): quteproc.turn_on_scroll_logging()
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2015-2016 Florian Bruhin (The Compiler) <*****@*****.**> # # 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
This module contains step definitions for table_filter.feature. """ import pytest from pytest_bdd import scenarios, given, when, then, parsers from selenium.webdriver.common.keys import Keys from dental.pages.task_filter.task_page import TaskFilter # Constants TASK_TABLE_URL = 'https://www.seleniumeasy.com/test/table-search-filter-demo.html' # Scenarios CONVERTERS = dict(criteria=str, occurrence=int) scenarios('../features/table_filter.feature', example_converters=CONVERTERS) # Given Steps @given("the task table is displayed") def go_to_task_page(driver): driver.get(TASK_TABLE_URL) # When Steps @when('i enter the task name as search <criteria>') @when('i enter the assignee name as search <criteria>') @when('i enter the task status as search <criteria>') @when('i enter an unavailable search <criteria>') @when(parsers.parse('i enter an unavailable search {criteria}')) def enter_task_name_as_search_criteria(driver, criteria):
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)
from pytest_bdd import scenarios, when, parsers, then from ui_tests.caseworker.pages.shared import Shared from ui_tests.caseworker.pages.users_page import UsersPage from ui_tests.caseworker.pages.roles_pages import RolesPages import tests_common.tools.helpers as utils scenarios("../features/roles.feature", strict_gherkin=False) @when("I go to manage roles") def go_to_manage_roles(driver): user_page = UsersPage(driver) user_page.click_on_manage_roles() @when( parsers.parse( 'I add a new role called "{role_name}" with permission to "{permissions}" and set status to "{status}"' )) def add_a_role(driver, role_name, permissions, status, context): roles_page = RolesPages(driver) roles_page.click_add_a_role_button() if role_name == " ": context.role_name = role_name else: context.role_name = f"{role_name} {utils.get_formatted_date_time_y_m_d_h_s()}"[: 25] roles_page.enter_role_name(context.role_name) roles_page.select_permissions(permissions)
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))
# SPDX-License-Identifier: AGPL-3.0-or-later """ Functional, browser based tests for ikiwiki app. """ from pytest_bdd import scenarios, then, when from plinth.tests import functional scenarios('ikiwiki.feature') @when('there is an ikiwiki wiki') def ikiwiki_create_wiki_if_needed(session_browser): _create_wiki_if_needed(session_browser) @when('I delete the ikiwiki wiki') def ikiwiki_delete_wiki(session_browser): _delete_wiki(session_browser) @then('the ikiwiki wiki should be restored') def ikiwiki_should_exist(session_browser): assert _wiki_exists(session_browser) def _create_wiki_if_needed(browser): """Create wiki if it does not exist.""" functional.nav_to_module(browser, 'ikiwiki') wiki = browser.find_link_by_href('/ikiwiki/wiki')
# 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 logging import pytest_bdd as bdd bdd.scenarios('open.feature') def test_open_s(quteproc, ssl_server): """Test :open with -s.""" quteproc.set_setting('content.ssl_strict', 'false') quteproc.send_cmd(':open -s http://localhost:{}/'.format(ssl_server.port)) quteproc.mark_expected(category='message', loglevel=logging.ERROR, message="Certificate error: *") quteproc.wait_for_load_finished('/', port=ssl_server.port, https=True, load_status='warn')
from pytest_bdd import scenarios from overhave import overhave_proxy_manager FEATURE_TYPE = "feature_type_3" pytest_plugins = overhave_proxy_manager().plugin_resolver.get_plugins(FEATURE_TYPE) scenarios(FEATURE_TYPE)
@then("the wavefunctions file has been copied over") def check_wfcn(tmpdir, extract): assert tmpdir.join("second", "pwscf.wfc1").check(file=True) expected_hash = tmpdir.join("first", "pwscf.wfc1").computehash() actual_hash = tmpdir.join("second", "pwscf.wfc1").computehash() assert expected_hash == actual_hash @then("the save directory has been copied over") def check_save_dir(tmpdir, extract): save_dir = tmpdir.join("second", "%s.save" % extract.prefix) assert save_dir.check(dir=True) assert save_dir.join('charge-density.dat').check(file=True) @then("pwscf is told to start from the wavefunction file") def check_start_from_wfcn(tmpdir): from pylada.espresso import Pwscf pwscf = Pwscf() pwscf.read(tmpdir.join("second", "pwscf.in")) assert pwscf.electrons.startingwfc == 'file' @then("the second run restarted form the wavefunctions") def check_restarted_from_wfc(passon): extract = passon[-1] assert extract.started_from_wavefunctions_file scenarios("features/restart.feature")
# # glimpsebrowser 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 glimpsebrowser. If not, see <http://www.gnu.org/licenses/>. import textwrap import pytest import pytest_bdd as bdd bdd.scenarios('hints.feature') @pytest.fixture(autouse=True) def set_up_word_hints(tmpdir, glimpseproc): dict_file = tmpdir / 'dict' dict_file.write( textwrap.dedent(""" one two three four five six seven eight
from tests.gui.steps.onezone.data_space_management import * from tests.gui.steps.onezone.providers import * from tests.gui.steps.onezone.manage_account import * from tests.gui.steps.oneprovider.data_tab import * from tests.gui.steps.oneprovider.file_browser import * from tests.gui.steps.oneservices.cdmi import * from tests.gui.steps.onezone_before_login import * from tests.gui.steps.onezone_provider_popup import * from tests.gui.steps.onezone_providers import * from tests.gui.steps.oneprovider_common import * from tests.gui.steps.oneprovider_data import * from tests.gui.steps.oneprovider_spaces import * from tests.gui.steps.oneprovider_shares import * from tests.gui.steps.oneprovider_metadata import * from tests.gui.steps.oneprovider_file_list import * from tests.gui.steps.oneprovider_sidebar_list import * from pytest_bdd import scenarios, scenario # --- FEATURES: all non-destructive (does not change state) --- scenarios('../features/oneprovider_2_providers_multi.feature') scenarios('../features/oneprovider_shares_multi.feature') scenarios('../features/oneprovider_group_multi.feature') scenarios('../features/onezone_gui_multi.feature')
# vim: ft=python fileencoding=utf-8 sw=4 et sts=4 # This file is part of vimiv. # Copyright 2017-2019 Christian Karl (karlch) <karlch at protonmail dot com> # License: GNU GPL v3, see the "LICENSE" and "AUTHORS" files for details. import pytest_bdd as bdd bdd.scenarios("expand_wildcards.feature")
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2016-2017 Florian Bruhin (The Compiler) <*****@*****.**> # # 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('utilcmds.feature')
import pytest from pytest_bdd import scenarios, given, when, then from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager # Scenario scenarios('../features/login.feature') # When @when('I click login button') def click_login_home_button(browser): button_login_home_id = browser.find_element_by_id('login_home') button_login_home_id.click() # Then @then('I should be on the Login form page') def get_title(browser): title = browser.title # print(title) assert title == "Login - Female Daily" # THen @then('I should see the email text field') def email_field_is_displayed(browser): email_field_id = browser.find_element_by_id('id-email-username') email_field_id.is_displayed() # Then @then('I should see the password text field') def password_field_is_displayed(browser):
from pytest_bdd import given, when, then, scenarios from boofuzz import Request, Block, Byte scenarios('block_original_value.feature') @given('A Block with contents') def request_one_block(context): request = Request(name="unit-test-request") block = Block(name="unit-test-block", request=request) request.push(block) byte1 = Byte(0x01, name="Byte block 1") request.push(byte1) request.pop() context.uut = block @given('Mutated once') def mutate_once(context): context.uut.mutate() @given('Mutated twice') def mutate_twice(context): context.uut.mutate() context.uut.mutate()
import ast import math # pytest is required as an extras_require: # noinspection PyPackageRequirements import pytest from pytest_bdd import given, parsers, scenarios, then, when from boofuzz import helpers from boofuzz.connections 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" )
# # 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('prompts.feature') @bdd.when("I load an SSL page") def load_ssl_page(quteproc, ssl_server): # We don't wait here as we can get an SSL question. quteproc.open_path('/', port=ssl_server.port, https=True, wait=False) @bdd.when("I wait until the SSL page finished loading") def wait_ssl_page_finished_loading(quteproc, ssl_server): quteproc.wait_for_load_finished('/', port=ssl_server.port, https=True, load_status='warn') @bdd.when("I wait for a prompt")
from pytest_bdd import scenarios scenarios('features/course_details_admin.feature', 'features/courses_list_admin.feature')
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2016-2017 Florian Bruhin (The Compiler) <*****@*****.**> # # 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('adblock.feature') @bdd.when(bdd.parsers.parse('I set up "{lists}" as block lists')) def set_up_blocking(quteproc, lists, httpbin): url = 'http://localhost:{}/data/adblock/'.format(httpbin.port) urls = [url + item.strip() for item in lists.split(',')] quteproc.set_setting('content', 'host-block-lists', ','.join(urls))
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2015-2020 Florian Bruhin (The Compiler) <*****@*****.**> # # 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('spawn.feature')
# 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 logging import pytest_bdd as bdd bdd.scenarios('sessions.feature') @bdd.when(bdd.parsers.parse('I have a "{name}" session file:\n{contents}')) def create_session_file(quteproc, name, contents): filename = os.path.join(quteproc.basedir, 'data', 'sessions', name + '.yml') with open(filename, 'w', encoding='utf-8') as f: f.write(contents) @bdd.when(bdd.parsers.parse('I replace "{pattern}" by "{replacement}" in the ' '"{name}" session file')) def session_replace(quteproc, server, pattern, replacement, name): # First wait until the session was actually saved quteproc.wait_for(category='message', loglevel=logging.INFO,
# vim: ft=python fileencoding=utf-8 sw=4 et sts=4 # This file is part of vimiv. # Copyright 2017-2021 Christian Karl (karlch) <karlch at protonmail dot com> # License: GNU GPL v3, see the "LICENSE" and "AUTHORS" files for details. import pytest_bdd as bdd from vimiv import startup bdd.scenarios("symlink.feature") @bdd.given("I open the symlink test directory") def open_symlink_test_directory(tmp_path): """Create a test directory with symlink(s) and open the base directory in vimiv. Structure: ├── lnstem -> stem └── stem └── leaf """ base_directory = tmp_path / "directory" stem_directory = base_directory / "stem" leaf_directory = stem_directory / "leaf" leaf_directory.mkdir(parents=True) stem_symlink = base_directory / "lnstem" stem_symlink.symlink_to(stem_directory) argv = [str(base_directory)] args = startup.setup_pre_app(argv) startup.setup_post_app(args)
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2015-2018 Florian Bruhin (The Compiler) <*****@*****.**> # # 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 # pylint: disable=unused-import from end2end.features.test_yankpaste_bdd import init_fake_clipboard bdd.scenarios('caret.feature')
# # 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('downloads.feature') @bdd.given("I set up a temporary download dir") def temporary_download_dir(quteproc, tmpdir): quteproc.set_setting('storage', 'prompt-download-directory', 'false') quteproc.set_setting('storage', 'remember-download-directory', 'false') quteproc.set_setting('storage', 'download-directory', str(tmpdir)) @bdd.given("I clean old downloads") def clean_old_downloads(quteproc): quteproc.send_cmd(':download-cancel --all') quteproc.send_cmd(':download-clear')
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2015 Florian Bruhin (The Compiler) <*****@*****.**> # # 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("navigate.feature")
from pytest_bdd import scenarios, given, when, then, parsers import pytest from .fake_upnp import create_fake_device from .async_utils import sync import asyncio import logging _logger = logging.getLogger(__name__) scenarios('discovery.feature') @given('a client listens for discovery events') @sync async def discovery_events_subscribed(event_bus_connection): result = await event_bus_connection.send(method='subscribe', params={'category': 'discovery'}) assert result is True @when(parsers.parse('a {device_type} {name} {action} the network')) def device_appears_or_leaves(test_context, name, action): assert action in ('appears on', 'leaves') if action == 'appears on': descriptor = create_fake_device(name) test_context.add_device_to_network(name, descriptor, notify=True) else: test_context.remove_device_to_network(name, notify=True) @when('the client unsubscribes for discovery events')
# (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 import pytest_bdd as bdd bdd.scenarios('yankpaste.feature') # https://github.com/The-Compiler/qutebrowser/issues/1124#issuecomment-158073581 pytestmark = pytest.mark.qt_log_ignore( '^QXcbClipboard: SelectionRequest too old', extend=True) @pytest.fixture(autouse=True) def skip_with_broken_clipboard(qtbot, qapp): """The clipboard seems to be broken on some platforms (OS X Yosemite?). This skips the tests if this is the case. """ clipboard = qapp.clipboard() with qtbot.waitSignal(clipboard.changed): clipboard.setText("Does this work?")
# # 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 <https://www.gnu.org/licenses/>. import pytest_bdd as bdd bdd.scenarios('invoke.feature') @bdd.when(bdd.parsers.parse("I spawn a new window")) def invoke_with(quteproc): """Spawn a new window via IPC call.""" quteproc.log_summary("Create a new window") quteproc.send_ipc([], target_arg='window') quteproc.wait_for(category='init', module='app', function='_open_startpage', message='Opening start pages')