Python pytest_bdd.given() Examples
The following are 15
code examples of pytest_bdd.given().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pytest_bdd
, or try the search function
.
Example #1
Source File: conftest.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
def wait_until_loaded(quteproc, path): """Wait until the given path is loaded (as per qutebrowser log).""" quteproc.wait_for_load_finished(path)
Example #2
Source File: conftest.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
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
Example #3
Source File: conftest.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
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)
Example #4
Source File: conftest.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
def wait_time(quteproc, delay): """Sleep for the given delay.""" time.sleep(float(delay))
Example #5
Source File: conftest.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
def press_keys(quteproc, keys): """Send the given fake keys to qutebrowser.""" quteproc.press_keys(keys)
Example #6
Source File: conftest.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
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)
Example #7
Source File: conftest.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
def path_should_be_requested(server, path): """Make sure the given path was loaded from the webserver.""" server.wait_for(verb='GET', path='/' + path)
Example #8
Source File: conftest.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
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
Example #9
Source File: conftest.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
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))
Example #10
Source File: conftest.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
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)
Example #11
Source File: conftest.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
def ensure_not_logged(quteproc, pattern): """Make sure the given pattern was *not* logged.""" quteproc.ensure_not_logged(message=pattern)
Example #12
Source File: conftest.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
def javascript_message_logged(quteproc, message): """Make sure the given message was logged via javascript.""" quteproc.wait_for_js(message)
Example #13
Source File: conftest.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
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))
Example #14
Source File: conftest.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
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)
Example #15
Source File: conftest.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
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)