Skip to content

Pytest-describe crashing with yarl.URL #47

@Null665

Description

@Null665

Hi, during Python version upgrade I've found a case where pytest-describe crashes when yarl.URL object is initialized under describe_ block.

test.py

import yarl

def describe_case():
    url = yarl.URL("url")

    def test_it():
        pass

requirementa.txt

pytest==8.2.2
pytest-describe==2.2.0
yarl==1.9.4

Output:

$ pytest test.py
================================================= test session starts =================================================
platform linux -- Python 3.11.7, pytest-8.2.2, pluggy-1.5.0
rootdir: /home/as/dev/nonproject/pytest-yarl-case
plugins: describe-2.2.0
collected 0 items / 1 error                                                                                           

======================================================= ERRORS ========================================================
______________________________________________ ERROR collecting test.py _______________________________________________
test.py:4: in describe_case
    url = yarl.URL("url")
.venv/lib/python3.11/site-packages/yarl/_url.py:200: in __new__
    path = cls._PATH_REQUOTER(val[2])
yarl/_quoting_c.pyx:204: in yarl._quoting_c._Quoter.__call__
    ???
.venv/lib/python3.11/site-packages/pytest_describe/plugin.py:18: in _trace_func
    if (frame.f_back.f_locals.get('_trace_func') == _trace_func
E   AttributeError: 'NoneType' object has no attribute 'f_locals'
=============================================== short test summary info ===============================================
ERROR test.py::describe_case - AttributeError: 'NoneType' object has no attribute 'f_locals'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================== 1 error in 0.12s ===================================================


This appears to happen since Python 3.11.
In a bigger test suite this ended up with segmentation fault, but I haven't been able to find minimal example.

My current workaround is to move the variables under fixtures or into test functions, which IMO should have been done from the start.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions