Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest.raises(AssertionError) fails with cython modules #176

Closed
pytestbot opened this issue Aug 8, 2012 · 3 comments
Closed

pytest.raises(AssertionError) fails with cython modules #176

pytestbot opened this issue Aug 8, 2012 · 3 comments
Labels
type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Jim Garrison (BitBucket: garrison, GitHub: garrison)


Define the files python_assert.py and cython_assert.pyx to be identical, each containing a simple function that raises AssertionError:

#!python
def raise_assertionerror():
    assert False

I would expect both of the following tests to succeed under pytest:

#!python
import pytest

import pyximport
pyximport.install()

from python_assert import raise_assertionerror as python_assert
from cython_assert import raise_assertionerror as cython_assert

def test_assertion():
    with pytest.raises(AssertionError):
        python_assert()

def test_cython_assertion():
    with pytest.raises(AssertionError):
        cython_assert()

However, the cython test fails.

This seems to be a problem with pytest because the equivalent unittest succeeds.

Further, the pytest test succeeds if we call pytest.raises(Exception) instead of pytest.raises(AssertionError).

Any idea what is wrong?


@pytestbot
Copy link
Contributor Author

Original comment by Jim Garrison (BitBucket: garrison, GitHub: garrison):


(Using pytest 2.2.4, cython 0.16, python 2.7.3)

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


thanks for the info - could you also attach/post the py.test invocation and its output?

@pytestbot
Copy link
Contributor Author

Original comment by Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt):


fix issue 176: raises(AssertionError) now catches builtin AssertionError as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

1 participant