Pytest Testing Idioms: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 2: Line 2:
* [[Pytest#Subjects|Pytest]]
* [[Pytest#Subjects|Pytest]]
=Overview=
=Overview=
=Tested Code is Supposed to Throw Exception=
<syntaxhighlight lang='python'>
import pytest
def test_something_that_should_throw_exception():
    with pytest.raises(Exception) as e_info:
        my_method()
</syntaxhighlight>

Revision as of 03:28, 16 February 2022

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()