Skip to content

Pytest can't handle custom classes in parameterized tests (major bug). #14560

@ketchupee1

Description

@ketchupee1

Hello.

I'm having an issue with Pytest where I'm unable to run parameterized tests with custom class objects.

Script path: ...\AppData\Local\Programs\Python\Python314\Lib\site-packages_pytest\python.py
Lineno: 1052

Error:
1052: in _idval_from_value
elif isinstance(getattr(val, "__name__", None), str):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E KeyError: '__name__'

(don't know why the above text is big and bold)

I should note that on my side, the test that now is unable to run had passed before about one week ago, and nothing has changed within the test script itself.

It seems to be that my custom class, which is basically a wrapper around the Python Dict builtin class, causes the error to now raise, whereas if I convert this to a normal python Dict, the tests passes again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions