InvocationError while 运行 flake8 in tox.ini

InvocationError while running flake8 in tox.ini


看起来我无法将相对路径或绝对路径传递给应该由 tox.ini 文件中的 flake8 检查的文件夹。

在 shell 中执行代码后:

flake8 tests/

结果正确:

tests/unit\test.py:17:91: E501 line too long (93 > 90 characters)

但是 tox 通过在命令提示符中键入来启动相同的命令:

tox

结果:

py38 installed: flake8==3.9.2,mccabe==0.6.1,pycodestyle==2.7.0,pyflakes==2.3.1
py38 run-test-pre: PYTHONHASHSEED='64'
py38 run-test: commands[0] | flake8 tests/
tests/unit\test.py:17:91: E501 line too long (93 > 90 characters)
ERROR: InvocationError for command 'C:\Users796\PycharmProjects\learningTests\.tox\py38\Scripts\flake8.EXE' tests/ (exited with code 1)
_______________________________________________________ summary _______________________________________________________
ERROR:   py38: commands failed

所以命令正常执行,然后运行出错。正如您在第三行中看到的那样 - 命令是相同的。

有什么想法吗?

因为 flake8 在您的代码中检测到错误,它以非零值退出

当 tox 检测到命令退出非零时,它会显示一个 InvocationError

一切正常:)


免责声明:我是当前的 flake8 维护者和 tox 核心开发者

当我在 PC 上时,我会仔细检查确切的错误消息,但你完全希望 tox 在一个环境中的命令之一失败时失败。

如果你只是想检查输出,但即使有问题命令也应该成功,你需要在命令前加上破折号 -.