The Python Oracle

How to properly assert that an exception gets raised in pytest?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Meditation

--

Chapters
00:00 Question
00:56 Accepted answer (Score 765)
02:48 Answer 2 (Score 309)
03:05 Answer 3 (Score 169)
03:55 Answer 4 (Score 91)
05:31 Thank you

--

Full question
https://stackoverflow.com/questions/2333...

Accepted answer links:
[pytest.raises(Exception)]: https://docs.pytest.org/en/stable/refere...

Answer 3 links:
[This comment]: https://stackoverflow.com/questions/2333...
[ilya-rusin]: https://stackoverflow.com/users/4863734/...

Answer 4 links:
[documentation]: https://docs.pytest.org/en/latest/assert...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #unittesting #testing #pytest

#avk47