We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Example
>>> from operator import attrgetter >>> from pytest_lazy_fixtures import lfc >>> lfc(attrgetter('id')) Traceback (most recent call last): File "<input>", line 1, in <module> File "/XXX/.venv/lib/python3.13/site-packages/pytest_lazy_fixtures/lazy_fixture_callable.py", line 33, in lfc return LazyFixtureCallableWrapper(name, *args, **kwargs) File "/XXX/.venv/lib/python3.13/site-packages/pytest_lazy_fixtures/lazy_fixture_callable.py", line 16, in __init__ self.name = func_or_name.__name__ ^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'operator.attrgetter' object has no attribute '__name__'. Did you mean: '__ne__'?
It seems that attrgetter doesn't have __name__. I don't know what the name is used for, but one solution is to use __class__.__name__ instead.
__name__
__class__.__name__
attrgetter is not the only problematic callable, the same happens for itemgetter and partial, I seems it's the case for all class-based callables:
attrgetter
itemgetter
partial
>>> class E: ... def __call__(self, *args, **kwargs): ... print('hello') >>> e = E() >>> e.__name__ Traceback (most recent call last): File "<input>", line 1, in <module> AttributeError: 'E' object has no attribute '__name__'. Did you mean: '__ne__'?
I changed line 16 in lazy_fixture_callable.py to
lazy_fixture_callable.py
try: self.name = func_or_name.__name__ except AttributeError: self.name = func_or_name.__class__.__name__
and my test using attrgetter passes, so maybe it's good enough
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Example
It seems that attrgetter doesn't have
__name__
. I don't know what the name is used for, but one solution is to use__class__.__name__
instead.attrgetter
is not the only problematic callable, the same happens foritemgetter
andpartial
, I seems it's the case for all class-based callables:I changed line 16 in
lazy_fixture_callable.py
toand my test using attrgetter passes, so maybe it's good enough
The text was updated successfully, but these errors were encountered: