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.
@nicoddemus It seems that pytest 3.0.3 re-introduces the failure fixed in 3.0.2. As you can see above, I've pinned Setuptools to 3.0.2 to allow the tests to continue to pass. I haven't had time yet to investigate. I think I should re-open this issue, although if you think it's better to open a new one, feel free to do that or suggest the same.
Fixed as discussed in pypa/setuptools#810.
I am observing this issue again, but I can't reproduce it locally...
For the record, pinning to <4.6 fixed the issue.
The real error is:
E TypeError: cannot unpack non-iterable NoneType object
Is it possible that the issue is triggered by test classes with > 20 tests?
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?
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
Yes, this will be fixed in 4.6.1, should be released soon.
what should I do if i see this on 4.6.3 ?
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.
Most helpful comment
The real error is:
See https://github.com/pytest-dev/pytest/issues/5358.