Pytests:获取错误函数不使用参数

2024-04-26 06:23:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下代码

@pytest.fixture
def mock_path_functions(mocker, file_exists=True, file_size=10):
    mock_obj = mock.Mock()
    mock_obj.st_size = file_size
    mocker.patch("os.path.exists", return_value=file_exists)
    mocker.patch("os.stat", return_value=mock_obj)

@pytest.mark.usefixtures("mock_path_functions")
@ytest.mark.parametrize("file_exists,file_size", [(False, 0)])
def test_subscrition_handle_from_file_when_file_is_not_present():
    assert subscrition_handle_from_file("some path") == None

但是,我得到以下错误:

In test_subscrition_handle_from_file_when_file_is_not_present: function uses no argument 'file_exists'

如何指定模拟路径函数的参数?你知道吗


Tags: pathfromobjsizepytestosdefexists

热门问题