---
title: "Discussion on \"How to Check if an Exception Is Raised (or Not) With pytest\" | Hashnode"
description: "Discussion on \"How to Check if an Exception Is Raised (or Not) With pytest\". Learn how to use pytest assert raises to test if your code raises an exception or not"
url: "https://hashnode.com/posts/how-to-check-if-an-exception-is-raised-or-not-with-pytest/5f9d342465cd015fab581bff"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How to Check if an Exception Is Raised (or Not) With pytest](https://miguendes.me/how-to-check-if-an-exception-is-raised-or-not-with-pytest?utm_source=hashnode&utm_medium=feed)

Learn how to use pytest assert raises to test if your code raises an exception or not

Oct 31, 2020 · 9 min read · miguendes.me  
Updated Jan 21, 2022  
Read the article

-   [#python](https://hashnode.com/tag/python)
-   [#pytest](https://hashnode.com/tag/pytest)
-   [#testing](https://hashnode.com/tag/testing)
-   [#unit-testing](https://hashnode.com/tag/unit-testing)

## Written by

[Miguel Brito](https://hashnode.com/@miguendes)

@miguendes · London, UK

  
[View profile](https://hashnode.com/@miguendes)

Machine Learning Software Engineer - Hobbyst Technical Writer - Interested in Software Testing, Best Practices, Scalability, and Python.

AI Software Engineer based in London, UK with 6+ years of professional experience developing and releasing software in different programming languages - Hobbyist Technical Writer - Interested in Software Testing, Best Practices, Scalability, Machine Learning/AI, and Python.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
