python - python mocks在'function'中找不到引用'assert_call_with'
问题描述
我在 python 中有这些简单的函数:
一个.py
def fn1(a, b):
return a + b
def fn1_reverted(a, b):
return fn1(b, a)
它的测试:
a_test.py
import a
def test_fn1():
assert a.fn1('a', 'b') == 'ab'
def test_fn1_reverted(mocker):
mocker.patch.object(a, 'fn1')
a.fn1_reverted('a', 'b')
a.fn1.assert_called_with('b', 'a')
我收到 pycharm 的警告:
Cannot find reference 'assert_called_with' in 'function'
难道我做错了什么?
这是断言使用特定参数调用内部函数的正确方法吗?
解决方案
推荐阅读
- laravel - Laravel 按需广播
- python - 用于内部转换的 pytransitions json 配置
- c++ - 为什么使用全局变量会使多线程执行速度减慢 2 倍,而在其他环境中却使其速度加快 2 倍?
- flutter - 我的列表在索引后不会更新事件
- c# - 优化 GameObject 唯一 ID 分配器 Unity
- powershell - 使用 PowerShell 监控共享文件夹的权限更改
- ruby-on-rails - 扩展设计以使用电话号码和 OTP 以及普通电子邮件和密码登录
- android - 如何在bottomSheet中检查recyclerview项目并通过bottomSheet中的按钮传递多个检查数据
- c++ - 为什么这个二进制文件容易受到缓冲区溢出的影响?
- android - 当视图滚出屏幕时使工具栏滚出