如何修复夹层单元测试失败?

时间:2013-02-11 06:39:43

标签: unit-testing mezzanine

当我运行单元测试时,我收到此错误:

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

追踪(最近一次呼叫最后一次):

  

文件“/Users/taylor/aco/lib/python2.7/site-packages/mezzanine/core/tests.py”,第459行,在test_syntax中

     

self.fail(“语法警告!\ n \ n%s”%“\ n”.join(警告))   AssertionError:语法警告!

     

mezzanine / core / models.py:340:list comprehension从第331行重新定义'name'

这是我运行单元测试时遇到的唯一错误,我到处搜索了解如何修复此错误,但我发现没有任何用处。 有人可以向我解释这里发生了什么以及如何解决它?

1 个答案:

答案 0 :(得分: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'...

对于它的价值,1.3.0中失败的test_syntax方法使用pyflakes.Checker和pep8 Python模块运行测试。文件mezzanine/core/models.py有(有?)语法错误。对commits的简短扫描表明test_syntax未发生变化。给出错误的具体语法是mezzanine.core.models.Orderable的{​​{3}}方法,它没有任何PEP8或pyflakes错误。当我对mezzanine.core.models的1.3.0版本运行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
相关问题