mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
Add a method to check Python exception types (#772)
This commit adds `error_already_set::matches()` convenience method to check if the exception trapped by `error_already_set` matches a given Python exception type. This will address #700 by providing a less verbose way to check exceptions.
This commit is contained in:
committed by
Dean Moldovan
parent
37ef74c584
commit
83a8a977a7
@@ -21,6 +21,11 @@ def test_python_call_in_catch():
|
||||
assert d["good"] is True
|
||||
|
||||
|
||||
def test_exception_matches():
|
||||
from pybind11_tests import exception_matches
|
||||
exception_matches()
|
||||
|
||||
|
||||
def test_custom(msg):
|
||||
from pybind11_tests import (MyException, MyException5, MyException5_1,
|
||||
throws1, throws2, throws3, throws4, throws5, throws5_1,
|
||||
|
||||
Reference in New Issue
Block a user