Skip to content

Fix flaky tests by cleaning a polluted state.#181

Open
sturmianseq wants to merge 2 commits intothegetty:masterfrom
sturmianseq:sturmianseq-patch-flaky
Open

Fix flaky tests by cleaning a polluted state.#181
sturmianseq wants to merge 2 commits intothegetty:masterfrom
sturmianseq:sturmianseq-patch-flaky

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