Based on the following example:
app = Flask(__name__)
@app.route('/users')
def get_users():
return UsersAPI().get_users()
And the following tests (using pytest
and pytest-mock
):
@pytest.fixture
def users():
return UsersAPI(how_many=1)
def test_simple(users, mocker):
mocker.patch("???", return_value=users)
I simply want to call UsersAPI(how_many=1)
instead of UsersAPI()
. Is this possible to do?
(if you know how to get done with unittest.mock
that is also fine since pytest-mock
is simply some pytest
wrapper)