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

AttributeError: 'Module' object has no attribute '_obj' #1944

Closed
axil opened this issue Sep 18, 2016 · 4 comments
Closed

AttributeError: 'Module' object has no attribute '_obj' #1944

axil opened this issue Sep 18, 2016 · 4 comments

Comments

@axil
Copy link

axil commented Sep 18, 2016

pytest generates an exception which is hard to understand:

% uname -a
Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt4-3 (2015-02-03) x86_64 GNU/Linux

% cat test.py
def f():
    return

assert f() == 10

% pytest test.py
platform linux -- Python 3.4.2, pytest-3.0.2, py-1.4.31, pluggy-0.3.1
___________________________ ERROR collecting test.py _____________________________
env/lib/python3.4/site-packages/_pytest/python.py:209: in fget
    return self._obj
E   AttributeError: 'Module' object has no attribute '_obj'

Seems to be the same issue as mentioned here:
pytest-dev/pytest-django#386

@axil
Copy link
Author

axil commented Sep 18, 2016

The same works with Python 2.7.9 (no AttributeError)

@The-Compiler
Copy link
Member

This is the full output:

_______________________ ERROR collecting test.py _______________________
/usr/lib/python3.5/site-packages/_pytest/python.py:209: in fget
    return self._obj
E   AttributeError: 'Module' object has no attribute '_obj'

During handling of the above exception, another exception occurred:
test.py:4: in <module>
    assert f() == 10
E   assert None == 10
E    +  where None = <function f at 0x7fada7dd11e0>()
!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!

the upper part is probably caused by Python 3's chained exception support and #1486.

axil pushed a commit to axil/pytest that referenced this issue Sep 18, 2016
@axil
Copy link
Author

axil commented Sep 18, 2016

Not something really universal, but this patch fixes the issue.

axil pushed a commit to axil/pytest that referenced this issue Sep 19, 2016
The-Compiler added a commit that referenced this issue Sep 20, 2016
AttributeError chaining bug #1944 fix
@nicoddemus
Copy link
Member

Resolved in master

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

3 participants