I kept forgetting how to assert exception messages in PyTest, so I finally checked the docs.

Here’s a reference snippet 🐍

#TIL #DailyPythonista #PyTest #TDD #Python #programming

https://borutzki.github.io/2026/03/30/how-to-assert-exception-message-in-pytest.html

You wouldn’t believe how many times I looked this up on Stack Overflow, and used solution proposed in the top thread found in Google.

Apparently not only I did it "the wrong way", but also wasted time each time for it (now I know I can just refer to IDE autocompletion for `raises` arguments).

API Reference - pytest documentation