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

Avoiding order dependency by altering pytest.fixture scope to function #3

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

Conversation

sturmianseq
Copy link

This PR aims to improve test reliability of tests in test_multiindex.py by avoiding order dependency by altering pytest.fixture scope to function.

The test can fail in this way by running pip3 install pytest-repeat; python3 -m pytest multiindex/tests/test_multiindex_hashed_non_unique.py --count=2
:

    def test_remove(mi):
        mi.remove('first_name', 'George')
>       assert len(mi.get('first_name', 'George')) == 1
E       AssertionError: assert 0 == 1
E        +  where 0 = len([])
E        +    where [] = <bound method MultiIndexContainer.get of <multiindex.multiindex.MultiIndexContainer object at 0x7f3aef5d51c0>>('first_name', 'George')
E        +      where <bound method MultiIndexContainer.get of <multiindex.multiindex.MultiIndexContainer object at 0x7f3aef5d51c0>> = <multiindex.multiindex.MultiIndexContainer object at 0x7f3aef5d51c0>.get

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.

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