agronholm / agronholm/typeguard

@typeguard on a test breaks pytest assertion rewriting

Open
#477 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
1.8k
Forks
145
Avg merge
8d 12h
Merged PRs (30d)
1

Description

### Things to check first

- [X] I have searched the existing issues and didn't find my bug already reported there

- [X] I have checked that my bug is still present in the latest release

### Typeguard version

4.3.0

### Python version

3.12

### What happened?

Install pytest and typeguard.
Run the following script:

```python
# test_example.py

import pytest

def test_example() -> None:
result = 1
assert result == 2

pytest.main()
```

See output including:

```
def test_example() -> None:
result = 1
> assert result == 2
E assert 1 == 2
```

Now run:

```python
# test_example.py

import pytest
from typeguard import typechecked

@typechecked
def test_example() -> None:
result = 1
assert result == 2

pytest.main()
```

See:

```
def test_example() -> None:
result = 1
> assert result == 2
E AssertionError
```

### How can we reproduce the bug?

Run the code examples from the previous section.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.