Django代码库测试在virtualenv

时间:2016-05-05 23:48:39

标签: python django virtualenv virtualenvwrapper

我在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。当我不是一个虚拟的时候,它们运行良好。我试过了:

  1. 创建一个新项目并运行测试,他们失败了 - 但至少我知道它与我的项目没有关系。
  2. 创建一个新的virtualenv并安装最低限度(例如只是Django)并针对裸项目进行测试,它们会失败。
  3. 创建一个新项目并在我的机器上添加所有内容,即使失败也是如此。
  4. 所有/大多数测试失败都与模块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
    

    我确定这是一个配置错误,但我不知道在哪里看这一点。

0 个答案:

没有答案