Changeset 0f65ea9 in mod_gnutls for test/mgstest


Ignore:
Timestamp:
Jan 3, 2020, 5:05:34 AM (19 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
asyncio, master, proxy-ticket
Children:
905063e
Parents:
076049a
Message:

Use post_check hook in 28_HTTP2_support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/mgstest/__init__.py

    r076049a r0f65ea9  
    11#!/usr/bin/python3
    22
    3 # Copyright 2019 Fiona Klute
     3# Copyright 2019-2020 Fiona Klute
    44#
    55# Licensed under the Apache License, Version 2.0 (the "License");
     
    6767            return m
    6868    return None
     69
     70
     71
     72def require_match(regexp, file, error_message=None):
     73    """Return the first match of the regular expression in file (by line),
     74    or raise TestExpectationFailed.
     75
     76    If error_message is not None the exception message will be that
     77    string, otherwise a generic message containing the regular
     78    expression pattern. Technically applicable to any iterable
     79    containing strings, not just files opened for reading.
     80
     81    """
     82    m = first_line_match(regexp, file)
     83    if m:
     84        return m
     85
     86    if error_message:
     87        raise TestExpectationFailed(error_message)
     88    else:
     89        raise TestExpectationFailed(f'No match found for {regexp.pattern}!')
Note: See TracChangeset for help on using the changeset viewer.