Skip to content

Improve test reliability by resetting parameters for test_todo_list_api tests #18

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sturmianseq
Copy link

This PR aims to improve the reliability of tests tests/test_view_boosters/test_todo_list_api/test_api_endpoints.py::test_multi_users_creation, tests/test_view_boosters/test_todo_list_api/test_api_endpoints.py::test_user_creation and tests/test_view_boosters/test_todo_list_api/test_relationship_updates.py::test_list_relationship_new_item by cleaning the state before running it.

The test can fail on the second run by running it twice. For example, you can run pip3 install pytest-repeat; python3 -m pytest --count=2 tests/test_view_boosters/test_todo_list_api/test_api_endpoints.py::test_multi_users_creation to get the following failure:

...
    def do_execute(self, cursor, statement, parameters, context=None):
>       cursor.execute(statement, parameters)
E       sqlite3.IntegrityError: UNIQUE constraint failed: user.email
...
==================== 1 failed, 1 passed, 1 warning in 0.88s ====================

More specifically, this PR initializes the parameters for each unit test. In this way, the tests do not fail on the second run any more. It may be better to avoid the state pollutions so that some other tests won't fail in the future due to the shared state pollution.

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.

1 participant