diff options
author | xoviat <xoviat@users.noreply.github.com> | 2017-12-28 18:25:12 -0600 |
---|---|---|
committer | xoviat <xoviat@users.noreply.github.com> | 2017-12-29 13:29:03 -0600 |
commit | cd155a4c40da767396b5c0168d12ebe18fa402bd (patch) | |
tree | f39ba2e65c354f85e07592127a31b167faa33466 /numpy/testing | |
parent | 7bb2d5a8f0219aa5acb5fda05929f1a0745a1883 (diff) | |
download | numpy-cd155a4c40da767396b5c0168d12ebe18fa402bd.tar.gz |
MAINT: simplify pytest assert_raises
Diffstat (limited to 'numpy/testing')
-rw-r--r-- | numpy/testing/pytest_tools/utils.py | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/numpy/testing/pytest_tools/utils.py b/numpy/testing/pytest_tools/utils.py index 19982ec54..8a0eb8be3 100644 --- a/numpy/testing/pytest_tools/utils.py +++ b/numpy/testing/pytest_tools/utils.py @@ -1219,16 +1219,9 @@ def assert_raises(exception_class, fn=None, *args, **kwargs): if fn is not None: pytest.raises(exception_class, fn, *args,**kwargs) else: - @contextlib.contextmanager - def assert_raises_context(): - try: - yield - except BaseException as raised_exception: - assert isinstance(raised_exception, exception_class) - else: - raise ValueError('Function did not raise an exception') + assert not kwargs - return assert_raises_context() + return pytest.raises(exception_class) def assert_raises_regex(exception_class, expected_regexp, *args, **kwargs): |