File size: 747 Bytes
cb65407
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Copyright cocotb contributors
# Licensed under the Revised BSD License, see LICENSE for details.
# SPDX-License-Identifier: BSD-3-Clause
"""
Common utilities shared by many tests in this directory
"""
import re
import traceback


async def _check_traceback(running_coro, exc_type, pattern, *match_args):
    try:
        await running_coro
    except exc_type:
        tb_text = traceback.format_exc()
    else:
        assert False, "Exception was not raised"

    assert re.match(pattern, tb_text, *match_args), (
        "Traceback didn't match - got:\n\n"
        f"{tb_text}\n"
        "which did not match the pattern:\n\n"
        f"{pattern}"
    )


class MyException(Exception):
    ...


class MyBaseException(BaseException):
    ...