Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to test that an exception was raise using pytest

# content of test_sysexit.py
import pytest


def f():
    raise SystemExit(1)


def test_mytest():
    with pytest.raises(SystemExit):
        f()
Source by docs.pytest.org #
 
PREVIOUS NEXT
Tagged: #test #exception #raise #pytest
ADD COMMENT
Topic
Name
3+3 =