{"action":"created","issue":{"url":"https://api.github.com/repos/pytest-dev/pytest-django/issues/386","repository_url":"https://api.github.com/repos/pytest-dev/pytest-django","labels_url":"https://api.github.com/repos/pytest-dev/pytest-django/issues/386/labels{/name}","comments_url":"https://api.github.com/repos/pytest-dev/pytest-django/issues/386/comments","events_url":"https://api.github.com/repos/pytest-dev/pytest-django/issues/386/events","html_url":"https://github.com/pytest-dev/pytest-django/issues/386","id":173322947,"number":386,"title":"AttributeError: 'Module' object has no attribute '_obj'","user":{"login":"aklaver","id":658260,"avatar_url":"https://avatars.githubusercontent.com/u/658260?v=3","gravatar_id":"","url":"https://api.github.com/users/aklaver","html_url":"https://github.com/aklaver","followers_url":"https://api.github.com/users/aklaver/followers","following_url":"https://api.github.com/users/aklaver/following{/other_user}","gists_url":"https://api.github.com/users/aklaver/gists{/gist_id}","starred_url":"https://api.github.com/users/aklaver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aklaver/subscriptions","organizations_url":"https://api.github.com/users/aklaver/orgs","repos_url":"https://api.github.com/users/aklaver/repos","events_url":"https://api.github.com/users/aklaver/events{/privacy}","received_events_url":"https://api.github.com/users/aklaver/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-08-25T22:11:30Z","updated_at":"2016-08-25T23:33:45Z","closed_at":null,"body":"Django 1.8.14\r\npytest==3.0.1\r\npytest-django-3.0.0\r\n\r\nThis code(a simplified version of real code):\r\n\r\n```\r\n#!/usr/bin/env python\r\n# -*- coding: utf-8 -*-\r\n\r\nimport pytest\r\nimport hplc_app.views as vw\r\n\r\n\r\nclass testClass(object):\r\n    pass\r\n\r\n\r\ndef testStr():\r\n    print('test')\r\n```\r\n\r\nGives this  Traceback\r\n```\r\n../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/_pytest/python.py:209: in fget\r\n    return self._obj\r\nE   AttributeError: 'Module' object has no attribute '_obj'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\ntests/test_test_views.py:6: in <module>\r\n    import hplc_app.views as vw\r\nhplc_app/views.py:24: in <module>\r\n    import hplc_app.forms as forms\r\nhplc_app/forms.py:17: in <module>\r\n    class DistrictForm(forms.Form):\r\nhplc_app/forms.py:20: in DistrictForm\r\n    district_list = [(d.district_id, d.district_short_name) for d in districts]\r\n../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/django/db/models/query.py:162: in __iter__\r\n    self._fetch_all()\r\n../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/django/db/models/query.py:965: in _fetch_all\r\n    self._result_cache = list(self.iterator())\r\n../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/django/db/models/query.py:238: in iterator\r\n    results = compiler.execute_sql()\r\n../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/django/db/models/sql/compiler.py:838: in execute_sql\r\n    cursor = self.connection.cursor()\r\n../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/django/db/backends/base/base.py:162: in cursor\r\n    cursor = self.make_debug_cursor(self._cursor())\r\n../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/django/db/backends/base/base.py:135: in _cursor\r\n    self.ensure_connection()\r\nE   Failed: Database access not allowed, use the \"django_db\" mark to enable it.\r\n\r\n```\r\nThe above combination of software works on other test files. Using pytest-django==2.9.1 also works\r\n"},"comment":{"url":"https://api.github.com/repos/pytest-dev/pytest-django/issues/comments/242579004","html_url":"https://github.com/pytest-dev/pytest-django/issues/386#issuecomment-242579004","issue_url":"https://api.github.com/repos/pytest-dev/pytest-django/issues/386","id":242579004,"user":{"login":"aklaver","id":658260,"avatar_url":"https://avatars.githubusercontent.com/u/658260?v=3","gravatar_id":"","url":"https://api.github.com/users/aklaver","html_url":"https://github.com/aklaver","followers_url":"https://api.github.com/users/aklaver/followers","following_url":"https://api.github.com/users/aklaver/following{/other_user}","gists_url":"https://api.github.com/users/aklaver/gists{/gist_id}","starred_url":"https://api.github.com/users/aklaver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aklaver/subscriptions","organizations_url":"https://api.github.com/users/aklaver/orgs","repos_url":"https://api.github.com/users/aklaver/repos","events_url":"https://api.github.com/users/aklaver/events{/privacy}","received_events_url":"https://api.github.com/users/aklaver/received_events","type":"User","site_admin":false},"created_at":"2016-08-25T23:33:45Z","updated_at":"2016-08-25T23:33:45Z","body":"The issue seems to be tied to pytest-django not pytest\r\nThe full output, also output further below from when I run with pytest-django==2.9.1 and same version of pytest:\r\n\r\n```\r\n(hplc_dj18_py3) aklaver@panda:~/py_virt/hplc_dj18_py3/hplc_site> pytest -v -s tests/test_test_views.py \r\n==================================================================== test session starts ====================================================================\r\nplatform linux -- Python 3.4.5, pytest-3.0.1, py-1.4.31, pluggy-0.3.1 -- /home/aklaver/py_virt/hplc_dj18_py3/bin/python3.4\r\ncachedir: .cache\r\nDjango settings: hplc_site.dev_settings (from environment variable)\r\nrootdir: /home/aklaver/software_projects/hplc_app/hplc_site, inifile: pytest.ini\r\nplugins: cov-2.3.1, django-3.0.0\r\ncollected 0 items / 1 errors \r\n\r\n========================================================================== ERRORS ===========================================================================\r\n_________________________________________________________ ERROR collecting tests/test_test_views.py _________________________________________________________\r\n../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/_pytest/python.py:209: in fget\r\n    return self._obj\r\nE   AttributeError: 'Module' object has no attribute '_obj'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\ntests/test_test_views.py:5: in <module>\r\n    import hplc_app.views as vw\r\nhplc_app/views.py:24: in <module>\r\n    import hplc_app.forms as forms\r\nhplc_app/forms.py:17: in <module>\r\n    class DistrictForm(forms.Form):\r\nhplc_app/forms.py:20: in DistrictForm\r\n    district_list = [(d.district_id, d.district_short_name) for d in districts]\r\n../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/django/db/models/query.py:162: in __iter__\r\n    self._fetch_all()\r\n../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/django/db/models/query.py:965: in _fetch_all\r\n    self._result_cache = list(self.iterator())\r\n../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/django/db/models/query.py:238: in iterator\r\n    results = compiler.execute_sql()\r\n../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/django/db/models/sql/compiler.py:838: in execute_sql\r\n    cursor = self.connection.cursor()\r\n../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/django/db/backends/base/base.py:162: in cursor\r\n    cursor = self.make_debug_cursor(self._cursor())\r\n../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/django/db/backends/base/base.py:135: in _cursor\r\n    self.ensure_connection()\r\nE   Failed: Database access not allowed, use the \"django_db\" mark to enable it.\r\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n```\r\n\r\n```\r\n(hplc_dj18_py3) aklaver@panda:~/py_virt/hplc_dj18_py3/hplc_site> pytest -v -s tests/test_test_views.py \r\n==================================================================== test session starts ====================================================================\r\nplatform linux -- Python 3.4.5, pytest-3.0.1, py-1.4.31, pluggy-0.3.1 -- /home/aklaver/py_virt/hplc_dj18_py3/bin/python3.4\r\ncachedir: .cache\r\ndjango settings: hplc_site.dev_settings (from environment variable)\r\nrootdir: /home/aklaver/software_projects/hplc_app/hplc_site, inifile: pytest.ini\r\nplugins: cov-2.3.1, django-2.9.1\r\ncollected 1 items \r\n\r\ntests/test_test_views.py::testStr test\r\nPASSED\r\n\r\n```"}}
{"actor":{"display_login":"aklaver"}}