Skip to content

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

Open
sturmianseq wants to merge 1 commit into
sushobhit27:masterfrom
sturmianseq:fix_test_multiindex_hashed_non_unique.py
Open

Avoiding order dependency by altering pytest.fixture scope to function#3
sturmianseq wants to merge 1 commit into
sushobhit27:masterfrom
sturmianseq:fix_test_multiindex_hashed_non_unique.py

Conversation

@sturmianseq

Copy link
Copy Markdown

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