gru*_*czy 5 testing django django-contrib django-authentication
当我运行我的django测试时,我得到以下错误,这些错误在我的测试套件之外:
======================================================================
ERROR: test_known_user (django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 160, in test_known_user
super(RemoteUserCustomTest, self).test_known_user()
File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 67, in test_known_user
self.assertEqual(response.context['user'].username, 'knownuser')
TypeError: 'NoneType' object is unsubscriptable
======================================================================
ERROR: test_last_login (django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 87, in test_last_login
self.assertNotEqual(default_login, response.context['user'].last_login)
TypeError: 'NoneType' object is unsubscriptable
======================================================================
ERROR: test_no_remote_user (django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 33, in test_no_remote_user
self.assert_(isinstance(response.context['user'], AnonymousUser))
TypeError: 'NoneType' object is unsubscriptable
======================================================================
ERROR: test_unknown_user (django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 168, in test_unknown_user
super(RemoteUserCustomTest, self).test_unknown_user()
File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 51, in test_unknown_user
self.assertEqual(response.context['user'].username, 'newuser')
TypeError: 'NoneType' object is unsubscriptable
======================================================================
ERROR: test_known_user (django.contrib.auth.tests.remote_user.RemoteUserNoCreateTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 67, in test_known_user
self.assertEqual(response.context['user'].username, 'knownuser')
TypeError: 'NoneType' object is unsubscriptable
======================================================================
ERROR: test_last_login (django.contrib.auth.tests.remote_user.RemoteUserNoCreateTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 87, in test_last_login
self.assertNotEqual(default_login, response.context['user'].last_login)
TypeError: 'NoneType' object is unsubscriptable
======================================================================
ERROR: test_no_remote_user (django.contrib.auth.tests.remote_user.RemoteUserNoCreateTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 33, in test_no_remote_user
self.assert_(isinstance(response.context['user'], AnonymousUser))
TypeError: 'NoneType' object is unsubscriptable
======================================================================
ERROR: test_unknown_user (django.contrib.auth.tests.remote_user.RemoteUserNoCreateTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 118, in test_unknown_user
self.assert_(isinstance(response.context['user'], AnonymousUser))
TypeError: 'NoneType' object is unsubscriptable
======================================================================
ERROR: test_known_user (django.contrib.auth.tests.remote_user.RemoteUserTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 67, in test_known_user
self.assertEqual(response.context['user'].username, 'knownuser')
TypeError: 'NoneType' object is unsubscriptable
======================================================================
ERROR: test_last_login (django.contrib.auth.tests.remote_user.RemoteUserTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 87, in test_last_login
self.assertNotEqual(default_login, response.context['user'].last_login)
TypeError: 'NoneType' object is unsubscriptable
======================================================================
ERROR: test_no_remote_user (django.contrib.auth.tests.remote_user.RemoteUserTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 33, in test_no_remote_user
self.assert_(isinstance(response.context['user'], AnonymousUser))
TypeError: 'NoneType' object is unsubscriptable
======================================================================
ERROR: test_unknown_user (django.contrib.auth.tests.remote_user.RemoteUserTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 51, in test_unknown_user
self.assertEqual(response.context['user'].username, 'newuser')
TypeError: 'NoneType' object is unsubscriptable
======================================================================
FAIL: test_current_site_in_context_after_login (django.contrib.auth.tests.views.LoginTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/views.py", line 190, in test_current_site_in_context_after_login
self.assertEquals(response.status_code, 200)
AssertionError: 302 != 200
Run Code Online (Sandbox Code Playgroud)
任何人都可以解释我,我做错了什么或我应该设置什么来让这些测试通过?
我通过执行以下操作成功地重现了您所看到的测试结果:
MIDDLEWARE_CLASSES = (
'django.middleware.cache.UpdateCacheMiddleware',
.... <your middleware classes> ....
'django.middleware.cache.FetchFromCacheMiddleware',
)
Run Code Online (Sandbox Code Playgroud)
如果有这些行,请尝试删除它们并重新运行单元测试。然而我对此没有解决方案。
| 归档时间: |
|
| 查看次数: |
1708 次 |
| 最近记录: |