This PR aims to improve test reliability of test test_api by resetting api.app.view_functions to the initial state by calling method clear
The test can fail in this way by running pip3 install pytest-repeat; python3 -m pytest --count=2 $test_path:
def test_api(app, person_list):
api = Api(app)
> api.route(person_list, 'person_list', '/persons', '/person_list')
...
if view_func is not None:
old_func = self.view_functions.get(endpoint)
if old_func is not None and old_func != view_func:
> raise AssertionError(
"View function mapping is overwriting an existing"
f" endpoint function: {endpoint}"
)
E AssertionError: View function mapping is overwriting an existing endpoint function: person_list
It may be better to clean state pollutions so that some other tests won't fail in the future due to the shared state pollution.
This PR aims to improve test reliability of test
test_api
by resettingapi.app.view_functions
to the initial state by calling methodclear
The test can fail in this way by running
pip3 install pytest-repeat; python3 -m pytest --count=2 $test_path
:It may be better to clean state pollutions so that some other tests won't fail in the future due to the shared state pollution.