flask-rest-jsonapi icon indicating copy to clipboard operation
flask-rest-jsonapi copied to clipboard

Resetting `api.app.view_functions` to the initial state

Open sturmianseq opened this issue 3 years ago • 0 comments

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.

sturmianseq avatar Aug 17 '21 04:08 sturmianseq