防止所有Python Unitests基于环境变量运行
如果某个环境变量未设置为特定值,我是否可以防止所有单元测试运行?
例如,我希望仅在os.getenv(db_url)
返回sqlite:///:memory:
时才能运行测试。
我想在全球配置此此类,因此我不需要查看每个测试类 /设置功能即可单独检查此功能。
Is there a way I could prevent all unit tests from running if a certain environment variable is not set to a specific value?
For example I want tests to only run if os.getenv(DB_URL)
returns sqlite:///:memory:
.
I'd like to configure this globally so I don't need to review every single test class / setup function to check this individually.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有很多方法可以实现这一目标,但是固定装置可能是最简单的
There's many ways to accomplish this, but a fixture is probably the easiest