-
Notifications
You must be signed in to change notification settings - Fork 352
Closed
Description
Django 1.8.14
pytest==3.0.1
pytest-django-3.0.0
This code(a simplified version of real code):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pytest
import hplc_app.views as vw
class testClass(object):
pass
def testStr():
print('test')
Gives this Traceback
../../../py_virt/hplc_dj18_py3/lib/python3.4/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:
tests/test_test_views.py:6: in <module>
import hplc_app.views as vw
hplc_app/views.py:24: in <module>
import hplc_app.forms as forms
hplc_app/forms.py:17: in <module>
class DistrictForm(forms.Form):
hplc_app/forms.py:20: in DistrictForm
district_list = [(d.district_id, d.district_short_name) for d in districts]
../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/django/db/models/query.py:162: in __iter__
self._fetch_all()
../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/django/db/models/query.py:965: in _fetch_all
self._result_cache = list(self.iterator())
../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/django/db/models/query.py:238: in iterator
results = compiler.execute_sql()
../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/django/db/models/sql/compiler.py:838: in execute_sql
cursor = self.connection.cursor()
../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/django/db/backends/base/base.py:162: in cursor
cursor = self.make_debug_cursor(self._cursor())
../../../py_virt/hplc_dj18_py3/lib/python3.4/site-packages/django/db/backends/base/base.py:135: in _cursor
self.ensure_connection()
E Failed: Database access not allowed, use the "django_db" mark to enable it.
The above combination of software works on other test files. Using pytest-django==2.9.1 also works
Metadata
Metadata
Assignees
Labels
No labels