我正在使用Pylint和鼻子,以及嗅探器,在每次保存时,我都会对我的python应用程序进行链接和测试。这是嗅探器,以防您不知道https://pypi.python.org/pypi/sniffer。
下面是负责运行嗅探器scent.py文件中的nosetest和pylint的可运行程序
from sniffer.api import * # import the really small API
from pylint import lint
from subprocess import call
import os
import nose
@runnable
def zimmer_tests(*args):
command = "nosetests some_module/test --nologcapture --with-coverage --cover-config-file=zimmer_coverage_config"
lint.Run(['some_module/app'], exit=False)
return call(command, shell=True) == 0
在这里,第一个lint.Run()
在我的应用程序上运行pylint。然后使用call()
在应用程序上执行nosetest。
问题是,在保存文件之后,nosetest运行在文件的更新版本上,但是Pylint使用的是相同的旧版本。为了获得新版本的文件,我每次都要重新启动嗅探器。
我认为这不是sniffer配置的问题,因为nosetest每次都能够获得新版本的文件。但我还是不确定。
我的pylintrc文件与生成命令pylint --generate-rcfile > .pylintrc
所得到的文件几乎相同,只需进行一些小的应用程序特定的调整。
发布于 2017-12-12 10:22:16
正如克劳斯所指出的。在注释中,lint.Run()
使用缓存中的文件,因为它是从一个仍在运行的进程中调用的。从命令行调用pylint按预期工作。
以下是修改后的代码
@runnable
def zimmer_tests(*args):
command_nose = "nosetests some_module/test --nologcapture --with-coverage --cover-config-file=zimmer_coverage_config"
command_lint = "pylint some_module"
call(command_lint, shell=True)
return call(command_nose, shell=True) == 0
https://stackoverflow.com/questions/47769535
复制相似问题