跳转到主要内容

pytest插件,用于运行时断言类型注解。

项目描述

https://img.shields.io/pypi/v/pytest-fixture-typecheck https://img.shields.io/pypi/l/pytest-fixture-typecheck

pytest-fixture-typecheck 是一个 pytest 插件,它会在运行时插入断言以检查你的测试用例是否使用了正确类型的 fixture。

问题

pytest 的 fixture 是 mypy 无法理解的魔法。这个类型检查非常好

@pytest.fixture
def myint():
    return 42

def test_basic(myint: str):
    assert myint == 42

这个测试通过了,但是类型注解是错误的。

使用这个 pytest 插件,即使通过类型检查,你的测试至少会失败。

如果你的测试没有类型注解,这个插件不会做任何事情。使用 mypy 来强制要求所有内容都有类型注解。

许可

公共领域许可。

由以下提供支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面