pytest.deprecated_call 含义 使用 含义 deprecated_call: 是一个上下文管理器,可确保代码块触发 DeprecationWarning 或者 PendingDeprecationWarning; 源码: deprecated_call 可以将函数当做参数传入,后面跟上参数。 使用 函数不传参 import warnings def api_call_v2(): warnings.warn('use v3 of this api', DeprecationWarning) return