Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resetting api.app.view_functions to the initial state #207

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sturmianseq
Copy link

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.

Copy link

@auvipy auvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants