python - Pytest:只运行 linter 检查(pytest-flake8),不运行测试
问题描述
我正在使用pytest-flake8插件来检查我的 Python 代码。每次我像这样运行棉绒:
pytest --flake8
除了 linting 之外,还运行所有测试。但我只想运行 linter 检查。
如何配置 pytest 使其仅对代码进行 lints 但跳过我的所有测试,最好通过命令行(或 conftest.py) -而不必在我的测试中添加跳过标记?
解决方案
如果您的所有测试都在一个目录中,那么Pytests--ignore <<path>>
选项在这里也很有效。
我通常将其隐藏在 make 命令后面。在这种情况下, myMakefile
和tests
directory 都位于存储库的根目录中。
.PHONY: lint
lint:
pytest --flake8 --ignore tests
推荐阅读
- azure - 向事件网格 API 连接验证系统分配的身份
- java - 如何使用 Java 从 Oracle 数据库中获取记录
- tensorflow - Tensorflow padding='SAME' 在卷积操作之前/之后应用
- android - 当我尝试在 kotlin 中声明意图时,android 应用程序在启动时崩溃
- elasticsearch - 通过 Presto 查询时 Elastic Search 索引的计数不同
- java - 为什么 Int 中 MAX_VALUE 的溢出使其为负值,但在字节中保持为正值?
- raku - 使用赋值运算符时,“方法‘ASSIGN-KEY’的调用者必须是对象实例”
- java - 为什么 jvm 中的默认 hashCode 生成切换到 JDK 8 中的 xor-shift?
- node.js - 如何在 prisma 中设置不同的数据库进行测试?
- postgresql - PostgreSQL 11 更高的分区表规划时间