[lang-ref] ( capture_return_code ) ( python )

def test_capture_return_code():
    # e.value.code
    import sys
    def run_illegal_operation():
        sys.exit(1)

    with pytest.raises(SystemExit) as e:
        run_illegal_operation()

    assert e.value.code == 1