How to write tests that expect errors¶
Define a helper that catches an error and returns its code:
Then test that specific expressions produce specific errors:
The pattern works because ea catches the error and en 0 returns its code. The comparison then checks for the expected error type.
See also: Catch errors, Check error codes