0

I have following code

@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

However I'm getting following error:

In test_subscrition_handle_from_file_when_file_is_not_present: function uses no argument 'file_exists'

How I can specify parameters to mock_path_function?

anish
  • 955
  • 4
  • 11
  • 26

1 Answers1

0

I think you just need to pass your arguments into your test function, like

@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(
    file_exists, file_size
):
    assert subscrition_handle_from_file("some path") == None