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

AssertionRewritingHook object has no attribute find_spec #1888

Closed
jaraco opened this issue Aug 29, 2016 · 11 comments
Closed

AssertionRewritingHook object has no attribute find_spec #1888

jaraco opened this issue Aug 29, 2016 · 11 comments
Labels

Comments

@jaraco
Copy link
Contributor

@jaraco jaraco commented Aug 29, 2016

Beginning with pytest 3.0.1, the tests in setuptools (example build) are failing with this error:

AttributeError: 'AssertionRewritingHook' object has no attribute 'find_spec'

This issue was not revealed with pytest 3.0.0 due to the issue with collection.

For now, setuptools is pinning to pytest 2.x (see pypa/setuptools#765) to work around the issue.

I expect this issue may be triggered by the (admittedly hacky) sandboxing that setuptools does, so setuptools may have some culpability. I have not researched the error further, so I welcome advice on what might be triggering this error.

@The-Compiler The-Compiler changed the title AssertRewritingHook object has no attribute find_spec AssertionRewritingHook object has no attribute find_spec Aug 30, 2016
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Aug 31, 2016
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Aug 31, 2016
nicoddemus added a commit to nicoddemus/setuptools that referenced this issue Aug 31, 2016
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Aug 31, 2016
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Aug 31, 2016
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Aug 31, 2016
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Aug 31, 2016
@astrojuanlu
Copy link

@astrojuanlu astrojuanlu commented Jun 2, 2019

I am observing this issue again, but I can't reproduce it locally...

https://circleci.com/gh/poliastro/poliastro/4018

astrojuanlu added a commit to astrojuanlu/poliastro that referenced this issue Jun 2, 2019
@astrojuanlu
Copy link

@astrojuanlu astrojuanlu commented Jun 2, 2019

For the record, pinning to <4.6 fixed the issue.

@blueyed
Copy link
Contributor

@blueyed blueyed commented Jun 2, 2019

The real error is:

E TypeError: cannot unpack non-iterable NoneType object

See #5358.

@licht1stein
Copy link

@licht1stein licht1stein commented Jun 2, 2019

Is it possible that the issue is triggered by test classes with > 20 tests?

@nicoddemus
Copy link
Member

@nicoddemus nicoddemus commented Jun 2, 2019

Is it possible that the issue is triggered by test classes with > 20 tests?

Yes, but can you please post the full output so we can check if it is the same problem?

@licht1stein
Copy link

@licht1stein licht1stein commented Jun 2, 2019

Is it possible that the issue is triggered by test classes with > 20 tests?

Yes, but can you please post the full output so we can check if it is the same problem?

Here it is below. Fixed by using pytest < 4.6

==================================== ERRORS ====================================
_________________ ERROR collecting test/models/test_country.py _________________
<frozen importlib._bootstrap>:900: in _find_spec
    ???
E   AttributeError: 'AssertionRewritingHook' object has no attribute 'find_spec'

During handling of the above exception, another exception occurred:
.venv/lib/python3.7/site-packages/py/_path/local.py:701: in pyimport
    __import__(modname)
<frozen importlib._bootstrap>:983: in _find_and_load
    ???
<frozen importlib._bootstrap>:963: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:902: in _find_spec
    ???
<frozen importlib._bootstrap>:876: in _find_spec_legacy
    ???
.venv/lib/python3.7/site-packages/_pytest/assertion/rewrite.py:169: in find_module
    source_stat, co = _rewrite_test(self.config, fn_pypath)
.venv/lib/python3.7/site-packages/_pytest/assertion/rewrite.py:404: in _rewrite_test
    rewrite_asserts(tree, fn, config)
.venv/lib/python3.7/site-packages/_pytest/assertion/rewrite.py:453: in rewrite_asserts
    AssertionRewriter(module_path, config).run(mod)
.venv/lib/python3.7/site-packages/_pytest/assertion/rewrite.py:701: in run
    new.extend(self.visit(child))
/usr/local/lib/python3.7/ast.py:262: in visit
    return visitor(node)
.venv/lib/python3.7/site-packages/_pytest/assertion/rewrite.py:828: in visit_Assert
    top_condition, explanation = self.visit(assert_.test)
E   TypeError: cannot unpack non-iterable NoneType object
@nicoddemus
Copy link
Member

@nicoddemus nicoddemus commented Jun 2, 2019

Yes, this will be fixed in 4.6.1, should be released soon.

@curlup
Copy link

@curlup curlup commented Oct 20, 2020

what should I do if i see this on 4.6.3 ?

@nicoddemus
Copy link
Member

@nicoddemus nicoddemus commented Oct 23, 2020

Hey @curlup,

what should I do if i see this on 4.6.3 ?

Probably report it as a bug, preferably with a small reproducible example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

6 participants
You can’t perform that action at this time.