votes up 2

Expected exception

Exception Class:

Raise code

def test_set_environ_raises_exception():
    """Tests set_environ will raise exceptions in context when the
    value parameter is None."""
    with pytest.raises(Exception) as exception:
        with set_environ('test1', None):
            raise Exception('Expected exception')

    assert 'Expected exception' in str(exception.value)
😲  Walkingbet is Android app that pays you real bitcoins for a walking. Withdrawable real money bonus is available now, hurry up! 🚶

Ways to fix

votes up 1 votes down

This exception is dropped by requests UnitTests.

with pytest.raises(Exception)

Just makes sure that the inner code will raise an exception.

The code:

raise Exception('Expected exception')

Makes raise itself.


assert 'Expected exception' in str(exception.value)

Checks that exception string is right

Jun 03, 2021 brucehardywald answer

Add a possible fix

Please authorize to post fix