GeezerVison is showing github.com — 8.3.4: approx broken when mixing numpy booleans and booleans · Issue #13047 · pytest-dev/pytest
8.3.4: approx broken when mixing numpy booleans and booleans #13047
Labels
type: bugproblem that needs to be addressedtype: regressionindicates a problem that was introduced in a release which was working previously Description
After updating to pytest 8.3.4 the following code
Python 3.11.10 (main, Nov 20 2024, 15:38:42) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytest
>>> import numpy as np
>>> np.False_ == pytest.approx(False)
returns False where as it returns True with pytest 8.3.3. I would not expect to have to update my code when updating to a patch version.
I would think, without having any clue, that #9354, is the culprit.
$pip list
Package Version
---------- -------
iniconfig 2.0.0
numpy 2.2.0
packaging 24.2
pip 24.0
pluggy 1.5.0
pytest 8.3.4
setuptools 65.5.0
OS: debian bookworm
Activity
RonnyPfannschmidt commented on Dec 9, 2024
nicoddemus commented on Dec 10, 2024
I would not expect to have to update my code when updating to a patch version.
Indeed, unfortunately even though we try our best, sometimes a bug fix might unexpectedly break a valid/existing case.
This is strange however, seems like the post example should work given that we have explicit tests for bool:
def test_expecting_bool(self) -> None:
assert True == approx(True) # noqa: E712
assert False == approx(False) # noqa: E712
assert True != approx(False) # noqa: E712
assert True != approx(False, abs=2) # noqa: E712
assert 1 != approx(True)
I guess throwing numpy.bool in the mix is causing unexpected problems.
t-b commented on Dec 15, 2024
Thanks both. Sorry for my wording. The rabbit hole got a bit too deep when debugging the problem and finding a pytest bug.
added a commit that references this issue
on Apr 2, 2025This issue will close once commit 0c45497 is merged into the 'main' branch.0c45497 added a commit that references this issue
on Apr 2, 2025This issue will close once commit 16c540f is merged into the 'main' branch.16c540f added a commit that references this issue
on Apr 2, 2025This issue will close once commit 70d0c9d is merged into the 'main' branch.70d0c9d
Metadata
Metadata
type: bugproblem that needs to be addressedtype: regressionindicates a problem that was introduced in a release which was working previously Development
No branches or pull requestsIssue actions