Skip to content

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

Closed
@pytestbot

Description

@pytestbot

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?


Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions