5
我不知道是否有一個用於pylint和/或pyflakes的插件?是否有用於鼻測試的pylint和pyflakes插件?
目前我正在使用coverage和tissue(PEP8)插件進行鼻子測試。
TNX提前
我不知道是否有一個用於pylint和/或pyflakes的插件?是否有用於鼻測試的pylint和pyflakes插件?
目前我正在使用coverage和tissue(PEP8)插件進行鼻子測試。
TNX提前
我曾經寫過一個使用Pyflakes測試發生器。這不是一個鼻子插件,但它是我需要足夠接近:
import os
import _ast
from pyflakes import checker
import your_application
TOP = os.path.dirname(os.path.dirname(your_application.__file__))
class PyflakesError(AssertionError):
def __str__(self):
path = self.args[0]
messages = self.args[1]
messages.sort(key=lambda m: m.lineno)
return 'checking %s\n' % path + '\n'.join(map(str, messages))
def check(path):
code = open(os.path.join(TOP, path)).read()
tree = compile(code, path, "exec", _ast.PyCF_ONLY_AST)
w = checker.Checker(tree, path)
if w.messages:
raise PyflakesError(path, w.messages)
def test():
for root, dirs, files in os.walk(TOP):
for name in files:
if not name.endswith('.py'):
continue
yield check, os.path.relpath(os.path.join(root, name), TOP)
def is_package(d):
return os.path.exists(os.path.join(root, d, '__init__.py'))
dirs[:] = filter(is_package, dirs)
的test
功能產量測試用例包含your_application
目錄內的每一個Python的文件。您可以根據需要調整TOP
以測試其他目錄。