Pytest Testing Idioms: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
=External=
=Internal=
=Internal=
* [[Pytest#Subjects|Pytest]]
* [[Pytest#Subjects|Pytest]]

Revision as of 21:38, 16 February 2022

External

Internal

Overview

Tested Code is Supposed to Throw Exception

import pytest

def test_something_that_should_throw_exception():
    with pytest.raises(Exception) as e_info:
        my_method()

  • How do I ensure a specific type of exception?
  • How to I test the exception message?

Also see:

Python Language | Exceptions