2010-11-04 179 views
0

我正在使用django-nonrel。當我在我的項目上運行manage.py test時,只包含一個非常簡單的用戶定義的測試,我在輸出中得到以下錯誤。有沒有人見過這個?我需要做些什麼來解決問題,以便test_shortcut_view (django.contrib.contenttypes.tests.ContentTypesTests)成功?Django框架測試失敗

/src/google_appengine/google/appengine/datastore/datastore_stub_util.py:21: DeprecationWarning: the md5 module is deprecated; use hashlib instead 
    import md5 
/src/google_appengine/google/appengine/api/memcache/__init__.py:31: DeprecationWarning: the sha module is deprecated; use the hashlib module instead 
    import sha 
/src/google_appengine/google/appengine/api/datastore_types.py:727: DeprecationWarning: object.__init__() takes no parameters 
    super(Email, self).__init__(self, email) 
............................................s.................F..................................................................................................... 
====================================================================== 
FAIL: test_shortcut_view (django.contrib.contenttypes.tests.ContentTypesTests) 
---------------------------------------------------------------------- 
Traceback (most recent call last): 
    File "/src/django/contrib/contenttypes/tests.py", line 66, in test_shortcut_view 
self.assertEqual("http://example.com/users/john/", response._headers.get("location")[1]) 
AssertionError: 'http://example.com/users/john/' != '/users/john/' 

---------------------------------------------------------------------- 
Ran 164 tests in 9.185s 

FAILED (failures=1, skipped=1) 

回答

1

那麼答案是在你的回溯:

self.assertEqual("http://example.com/users/john/", response._headers.get("location")[1]) 
AssertionError: 'http://example.com/users/john/' != '/users/john/' 

變化拳頭行:

self.assertEqual("https://stackoverflow.com/users/john/", response._headers.get("location")[1]) 

應該解決的考驗。但是如果你的測試代碼沒有寫出來,我認爲問題出在example.com/part上。 example.com可能來自您的網站設置。有一種稱爲網站的模型,如果您將其更改爲正確的網址,則可能有效。

你可以嘗試使用不同的django版本。幹線與穩定版本在測試過程中表現不同。

+0

看起來像它在django-nonrel的版本中存在的一個問題,而我不是那種需要通過配置或類似方法解決的問題。謝謝! – 2010-11-06 09:11:57

0

失敗是由默認的django設置附帶的單元測試引起的。

他們希望你能使用管理界面配置默認網站:

例如http://localhost:8000/admin/sites/ 並有 SITE_ID = 1

檢查網站ID引用一個有效的條目

http://localhost:8000/admin/sites/site/1/其中1爲您的網站ID。

-

使用網站的應用程序是可選的,你可以刪除: 'django.contrib.sites', 從應用列表。