attrs
attrs copied to clipboard
`tests/test_make.py::TestClassBuilder::test_handles_missing_meta_on_class` test regression on PyPy3.x 7.3.19
I don't really know why CI doesn't reproduce this, but I'm seeing it both with PyPy3.10 and PyPy3.11, 7.3.19 and latest nightly.
$ tox -e pypy310-tests,pypy311-tests
.pkg: _optional_hooks> python /usr/lib/python3.13/site-packages/pyproject_api/_backend.py True hatchling.build
.pkg: get_requires_for_build_wheel> python /usr/lib/python3.13/site-packages/pyproject_api/_backend.py True hatchling.build
.pkg: get_requires_for_build_editable> python /usr/lib/python3.13/site-packages/pyproject_api/_backend.py True hatchling.build
.pkg: build_wheel> python /usr/lib/python3.13/site-packages/pyproject_api/_backend.py True hatchling.build
pypy310-tests: install_package> python -I -m pip install --force-reinstall --no-deps /tmp/attrs/.tox/.tmp/package/15/attrs-25.2.1.dev2-py3-none-any.whl
pypy310-tests: commands[0]> pytest -n auto
========================================================= test session starts =========================================================
platform linux -- Python 3.10.16[pypy-7.3.19-final], pytest-8.3.5, pluggy-1.5.0
cachedir: .tox/pypy310-tests/.pytest_cache
rootdir: /tmp/attrs
configfile: pyproject.toml
testpaths: tests
plugins: xdist-3.6.1, hypothesis-6.129.0
6 workers [1346 items] skipped
......................................................................s......s................................................. [ 9%]
..........................................................................s..s................................................. [ 18%]
............................................................................................................................... [ 28%]
............................................................................................................................... [ 37%]
..............................................................................................................s..s.s........... [ 47%]
............................................................................................................................... [ 56%]
..............................F................................................................................................ [ 66%]
...................s............................................ss...................................................x......... [ 75%]
.................s............................................................................................................. [ 84%]
............................................................................................................................... [ 94%]
............................................................................ [100%]
============================================================== FAILURES ===============================================================
_________________________________________ TestClassBuilder.test_handles_missing_meta_on_class _________________________________________
[gw2] linux -- Python 3.10.16 /tmp/attrs/.tox/pypy310-tests/bin/python
self = <tests.test_make.TestClassBuilder object at 0x00007f9f6946b520>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x00007f9f69e36bb8>
def test_handles_missing_meta_on_class(
self, monkeypatch: pytest.MonkeyPatch
):
"""
If the class hasn't a __module__ or __qualname__, the method hasn't
either.
"""
class C:
pass
> orig_hasattr = __builtins__["hasattr"]
E TypeError: 'module' object is not subscriptable (key 'hasattr')
tests/test_make.py:1823: TypeError
======================================================= short test summary info =======================================================
SKIPPED [1] tests/test_3rd_party.py:14: could not import 'cloudpickle': No module named 'cloudpickle'
SKIPPED [2] tests/test_annotations.py:97: Incompatible behavior on older Pythons
SKIPPED [2] tests/test_annotations.py:391: Incompatible behavior on older Pythons
SKIPPED [1] tests/test_functional.py:775: requires Python 3.13+
SKIPPED [1] tests/test_functional.py:784: requires Python 3.13+
SKIPPED [1] tests/test_functional.py:798: requires Python 3.13+
SKIPPED [1] tests/test_make.py:2620: Pre-3.10 only.
SKIPPED [1] tests/test_pyright.py:35: Requires pyright.
SKIPPED [1] tests/test_pyright.py:83: Requires pyright.
SKIPPED [1] tests/test_slots.py:487: __slots__ only block weakref on CPython
XFAIL tests/test_setattr.py::TestSetAttr::test_slotted_confused
FAILED tests/test_make.py::TestClassBuilder::test_handles_missing_meta_on_class - TypeError: 'module' object is not subscriptable (key 'hasattr')
======================================= 1 failed, 1333 passed, 12 skipped, 1 xfailed in 12.08s ========================================
pypy310-tests: exit 1 (13.13 seconds) /tmp/attrs> pytest -n auto pid=403254
pypy310-tests: FAIL ✖ in 14.93 seconds
pypy311-tests: install_package> python -I -m pip install --force-reinstall --no-deps /tmp/attrs/.tox/.tmp/package/16/attrs-25.2.1.dev2-py3-none-any.whl
pypy311-tests: commands[0]> pytest -n auto
========================================================= test session starts =========================================================
platform linux -- Python 3.11.11[pypy-7.3.19-final], pytest-8.3.5, pluggy-1.5.0
cachedir: .tox/pypy311-tests/.pytest_cache
rootdir: /tmp/attrs
configfile: pyproject.toml
testpaths: tests
plugins: xdist-3.6.1, hypothesis-6.129.0
6 workers [1346 items] skipped
............................................................................................................................... [ 9%]
............................................................................................................................... [ 18%]
............................................................................................................................... [ 28%]
............................................................................................................................... [ 37%]
............................................................................................................................... [ 47%]
..........................................ss....s.............................................................................. [ 56%]
............................................................................................................................... [ 66%]
.s...................................................................ss........................................................ [ 75%]
x.......................s...................................................................................................... [ 84%]
............................................................................................................................... [ 94%]
..........................................................F................. [100%]
============================================================== FAILURES ===============================================================
_________________________________________ TestClassBuilder.test_handles_missing_meta_on_class _________________________________________
[gw4] linux -- Python 3.11.11 /tmp/attrs/.tox/pypy311-tests/bin/python
self = <tests.test_make.TestClassBuilder object at 0x00007f1cb0bc52f0>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x00005642655e0c60>
def test_handles_missing_meta_on_class(
self, monkeypatch: pytest.MonkeyPatch
):
"""
If the class hasn't a __module__ or __qualname__, the method hasn't
either.
"""
class C:
pass
> orig_hasattr = __builtins__["hasattr"]
E TypeError: 'module' object is not subscriptable (key 'hasattr')
tests/test_make.py:1823: TypeError
======================================================= short test summary info =======================================================
SKIPPED [1] tests/test_3rd_party.py:14: could not import 'cloudpickle': No module named 'cloudpickle'
SKIPPED [1] tests/test_functional.py:775: requires Python 3.13+
SKIPPED [1] tests/test_functional.py:784: requires Python 3.13+
SKIPPED [1] tests/test_functional.py:798: requires Python 3.13+
SKIPPED [1] tests/test_make.py:2620: Pre-3.10 only.
SKIPPED [1] tests/test_pyright.py:35: Requires pyright.
SKIPPED [1] tests/test_pyright.py:83: Requires pyright.
SKIPPED [1] tests/test_slots.py:487: __slots__ only block weakref on CPython
XFAIL tests/test_setattr.py::TestSetAttr::test_slotted_confused
FAILED tests/test_make.py::TestClassBuilder::test_handles_missing_meta_on_class - TypeError: 'module' object is not subscriptable (key 'hasattr')
======================================== 1 failed, 1337 passed, 8 skipped, 1 xfailed in 10.43s ========================================
pypy311-tests: exit 1 (11.08 seconds) /tmp/attrs> pytest -n auto pid=404374
.pkg: _exit> python /usr/lib/python3.13/site-packages/pyproject_api/_backend.py True hatchling.build
pypy310-tests: FAIL code 1 (14.93=setup[1.80]+cmd[13.13] seconds)
pypy311-tests: FAIL code 1 (11.93=setup[0.85]+cmd[11.08] seconds)
evaluation failed :( (27.00 seconds)
Git bisect points to 74007f67d203f902e88bdecba169786bf44a8aa2.
I don't really know why CI doesn't reproduce this, but I'm seeing it both with PyPy3.10 and PyPy3.11, 7.3.19 and latest nightly.
PyPy is extremely slow for tests, so we started running it only against our functional tests:
https://github.com/python-attrs/attrs/blob/ba3bbfe7e13d96e592f0f4491affc5764ab27c49/tox.ini#L31
I'm not 100% sure what to do about this. I don't mind merging a PR that fixes it, but this can happen anytime again, since we don't run the full test suite under PyPy.
PyPy is extremely slow for tests
That's weird. I didn't notice much of a difference between CPython and PyPy here, at least with the baseline tox targets. It could be due to -n6 coming from xdist, though.