If your testing framework does not have helpers for that, or you are not using any, you can do this only using builtins by
using try .. except .. else and isinstance:
>>> def f(): # define a function which AssertionErrors.
... assert False
...
>>> f() # as expected, it does
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in f
AssertionError
>>> try: # wrap it
... f()
... except Exception as e: # and assert it really does
... assert isinstance(e, AssertionError)
... else:
... raise AssertionError("There was'nt any Exception, but we expected an AssertionError!")
...
>>>
or just catch the AssertionError explicitly:
>>> try:
... f()
... except AssertionError:
... pass # all good, we got an AssertionError
... except Exception:
... raise AssertionError("There was an Exception, but it wasn't an AssertionError!")
... else:
... raise AssertionError("There was'nt any Exception, but we expected an AssertionError!")
...