2013-02-11 43 views
2

當我運行我的單元測試,我得到這個錯誤:如何解決夾層單元測試失敗?

FAIL: test_syntax (mezzanine.core.tests.Tests) 

回溯(最近通話最後一個):

File "/Users/taylor/aco/lib/python2.7/site-packages/mezzanine/core/tests.py", line 459, in test_syntax

self.fail("Syntax warnings!\n\n%s" % "\n".join(warnings)) AssertionError: Syntax warnings!

mezzanine/core/models.py:340: list comprehension redefines 'name' from line 331

這是唯一的錯誤,當我跑我的單位,我得到測試和我到處搜索找出如何解決這個錯誤,但我沒有發現什麼有用的。 有人可以請我解釋一下這裏發生了什麼,我該如何解決它?

回答

1

我認爲你正在運行Mezzanine 1.3.0,目前的穩定版本。 github中的當前主分支沒有這個問題。我剛安裝執行以下操作:

$ pip install git+https://github.com/stephenmcd/mezzanine.git#egg=Mezzanine 
$ mezzanine-project project 
$ python project/manage.py test 
Creating test database for alias 'default'... 
................................................................................. 
................................................................................. 
................................................................................. 
...............................s......s..................................s....... 
................................................................ 
---------------------------------------------------------------------- 
Ran 388 tests in 30.556s 

OK (skipped=3) 
Destroying test database for alias 'default'... 

對於什麼是值得的,在test_syntax方法是在1.3.0運行與pyflakes.Checker測試和PEP8 Python模塊失敗。文件mezzanine/core/models.py有(有?)語法錯誤。對commits的簡要掃描表明test_syntax未更改。給出錯誤的特定語法是mezzanine.core.models.Orderablewith_respect_to方法,它沒有任何PEP8或pyflakes錯誤。當我針對1.3.0版本的mezzanine.core.models運行pyflakes時:

$ pyflakes ../lib/python2.6/site-packages/mezzanine/core/models.py 
../lib/python2.6/site-packages/mezzanine/core/models.py:340: list comprehension 
redefines 'name' from line 331