Skip to content

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

Closed

Description

@axil

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

Activity

  1. axil commented on Sep 18, 2016

    @axil
    Author

    The same works with Python 2.7.9 (no AttributeError)

  2. The-Compiler commented on Sep 18, 2016

    @The-Compiler
    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.

  3. added a commit that references this issue on Sep 18, 2016
  4. axil commented on Sep 18, 2016

    @axil
    Author

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

  5. added a commit that references this issue on Sep 19, 2016
  6. added a commit that references this issue on Sep 20, 2016
  7. nicoddemus commented on Sep 26, 2016

    @nicoddemus
    Member

    Resolved in master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions