当使用与pytest fixture集成的mock包中的patch decorator时,我遇到了一些神秘的东西.
我有两个模块
-----test folder
-------func.py
-------test_test.py
Run Code Online (Sandbox Code Playgroud)
在func.py中:
def a():
return 1
def b():
return a()
Run Code Online (Sandbox Code Playgroud)
在test_test.py中
import pytest
from func import a,b
from mock import patch,Mock
@pytest.fixture(scope="module")
def brands():
return 1
mock_b=Mock()
@patch('test_test.b',mock_b)
def test_compute_scores(brands):
a()
Run Code Online (Sandbox Code Playgroud)
似乎补丁装饰与pytest fixture不兼容.有没有人对此有所了解?Tnanks