Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

object has no attribute '_memoizedcall' on pytest 6.x #34

Closed
b0g3r opened this issue Oct 17, 2020 · 5 comments
Closed

object has no attribute '_memoizedcall' on pytest 6.x #34

b0g3r opened this issue Oct 17, 2020 · 5 comments

Comments

@b0g3r
Copy link

b0g3r commented Oct 17, 2020

Hi there! I started to use your library for one of my new projects and faced up with the exception like this:

tests/api/personal/test_change_password.py:None (tests/api/personal/test_change_password.py)
.venv/lib/python3.9/site-packages/pytest_describe/plugin.py:134: in _getobj
    return self._memoizedcall('_obj', self._importtestmodule)
E   AttributeError: 'DescribeBlock' object has no attribute '_memoizedcall'

I wrote a little example:

import pytest


@pytest.fixture()
def truelness():
    return True

def describe_pytest_describe():
    def should_work_on_pytest_6():
        assert True


def describe_pytest_describe_with_fixture(truelness):
    def should_work_on_pytest_6():
        assert truelness is True

output:

================================================================================================================ ERRORS ================================================================================================================
________________________________________________________________________________________________ ERROR collecting tests/test_example.py ________________________________________________________________________________________________
.venv/lib/python3.9/site-packages/pytest_describe/plugin.py:134: in _getobj
    return self._memoizedcall('_obj', self._importtestmodule)
E   AttributeError: 'DescribeBlock' object has no attribute '_memoizedcall'

During handling of the above exception, another exception occurred:
.venv/lib/python3.9/site-packages/pytest_describe/plugin.py:136: in _getobj
    return self._importtestmodule()
.venv/lib/python3.9/site-packages/pytest_describe/plugin.py:144: in _importtestmodule
    module = make_module_from_function(self.funcobj)
.venv/lib/python3.9/site-packages/pytest_describe/plugin.py:37: in make_module_from_function
    module.__dict__.update(trace_function(funcobj))
.venv/lib/python3.9/site-packages/pytest_describe/plugin.py:19: in trace_function
    funcobj(*args, **kwargs)
E   TypeError: describe_pytest_describe_with_fixture() missing 1 required positional argument: 'truelness'
======================================================================================================= short test summary info ========================================================================================================
ERROR tests/test_example.py - TypeError: describe_pytest_describe_with_fixture() missing 1 required positional argument: 'truelness'

It looks like a problem with this specific commit in pytest: pytest-dev/pytest@ceb0165

Could you please take a look?

@jacebrowning
Copy link
Contributor

@b0g3r are you able to reproduce this with the unreleased version in the master branch?

@ROpdebee
Copy link
Contributor

ROpdebee commented Nov 1, 2020

Not OP but can confirm the _memoizedcall error is gone on master for me (python 3.8.2, pytest 6.1.2). The example above still fails because the fixture isn't injected into the describe block, which I can reproduce on pytest 5.4.3 as well, although that may be a different issue.

@b0g3r
Copy link
Author

b0g3r commented Nov 1, 2020

Oops, my bad, my intuition told me that it should work like this 🙇‍♂️

@ROpdebee
Copy link
Contributor

ROpdebee commented Nov 1, 2020

Fixture issue is related to #9 and #11, it's been a few years so it might be worthwhile to re-evaluate whether it'd be possible to inject fixtures into describe blocks (perhaps limited to class-scope fixtures?)

@Cito
Copy link
Member

Cito commented Aug 18, 2021

This should be fixed in 2.0. The fixture issue is now covered in #38. Any help with that one is appreciated.

@Cito Cito closed this as completed Aug 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants