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

Fix flaky tests by cleaning a polluted state. #181

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

Conversation

sturmianseq
Copy link

@sturmianseq sturmianseq commented Nov 15, 2021

What is the purpose of the change

This PR is to fix flaky tests tests/test_model.py::TestMagicMethods::test_not_multiple_instance, tests/test_model.py::TestMagicMethods::test_validate_multiplicity after running tests/test_model.py::TestAutoIdentifiers::test_bad_autoid, but pass when they are run in isolation.

Reproduce the test failure

Run the following command:

python -m pytest tests/test_model.py::TestAutoIdentifiers::test_bad_autoid tests/test_model.py::TestMagicMethods::test_not_multiple_instance

python -m pytest tests/test_model.py::TestAutoIdentifiers::test_bad_autoid tests/test_model.py::TestMagicMethods::test_validate_multiplicity

Expexted result

Test tests/test_model.py::TestMagicMethods::test_not_multiple_instance and tests/test_model.py::TestMagicMethods::test_validate_multiplicity should pass after running tests/test_model.py::TestAutoIdentifiers::test_bad_autoid.

Actual result

tests/test_model.py::TestMagicMethods::test_not_multiple_instance and tests/test_model.py::TestMagicMethods::test_validate_multiplicity fail:

        else:
>               raise ConfigurationError("Unknown auto-id type")
E     cromulent.model.ConfigurationError: Unknown auto-id type

cromulent/model.py:281: ConfigurationError

Why they fail

model.factory.auto_id_type is polluted after tests/test_model.py::TestAutoIdentifiers::test_bad_autoid

Fix

Reset model.factory.auto_id_type to int-per-segment at the end of tests/test_model.py::TestAutoIdentifiers::test_bad_autoid to avoid flaky tests.

@sturmianseq sturmianseq changed the title Fix a flaky test by cleaning a polluted state. Fix flaky tests by cleaning a polluted state. Nov 15, 2021
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