Skip to content

Instantly share code, notes, and snippets.

@headsrooms
Created August 14, 2018 09:59
Show Gist options
  • Save headsrooms/e63abb18c70c02e3a97fb8e47dbb818f to your computer and use it in GitHub Desktop.
Save headsrooms/e63abb18c70c02e3a97fb8e47dbb818f to your computer and use it in GitHub Desktop.
Test util to check that some code not raises an exception
from contextlib import contextmanager
import pytest
@contextmanager
def not_raises(exception):
try:
yield
except exception as e:
print(e)
raise pytest.fail("DID RAISE {0}".format(exception))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment