我在Ubuntu 14.04上使用Django 1.3.1,python 2.7.6,virtualenv 13.1.2和virtualenvwrapper 4.7.1。
我一直试图让Django单元测试(不是我自己的测试,Django功能本身的测试)运行干净,准备从Django 1.3.1升级到当前版本但是它们一直都失败了在virtualenv。当我不是一个虚拟的时候,它们运行良好。我试过了:
所有/大多数测试失败都与模块django.contrib.auth.tests.forms
有关,其中几个如下所示:
======================================================================
FAIL: test_success (django.contrib.auth.tests.forms.AuthenticationFormTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jasonwong/.virtualenvs/testagain/local/lib/python2.7/site-packages/django/contrib/auth/tests/forms.py", line 112, in test_success
self.assertTrue(form.is_valid())
AssertionError: False is not true
======================================================================
FAIL: test_password_change_fails_with_invalid_old_password (django.contrib.auth.tests.views.ChangePasswordTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jasonwong/.virtualenvs/testagain/local/lib/python2.7/site-packages/django/contrib/auth/tests/views.py", line 162, in test_password_change_fails_with_invalid_old_password
self.login()
File "/home/jasonwong/.virtualenvs/testagain/local/lib/python2.7/site-packages/django/contrib/auth/tests/views.py", line 43, in login
self.assertEqual(response.status_code, 302)
AssertionError: 200 != 302
======================================================================
FAIL: test_password_change_fails_with_mismatched_passwords (django.contrib.auth.tests.views.ChangePasswordTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jasonwong/.virtualenvs/testagain/local/lib/python2.7/site-packages/django/contrib/auth/tests/views.py", line 173, in test_password_change_fails_with_mismatched_passwords
self.login()
File "/home/jasonwong/.virtualenvs/testagain/local/lib/python2.7/site-packages/django/contrib/auth/tests/views.py", line 43, in login
self.assertEqual(response.status_code, 302)
AssertionError: 200 != 302
我确定这是一个配置错误,但我不知道在哪里看这一点。