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 test on test_dictionary.py::test_dictionary_looping #2105

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions codespell_lib/tests/test_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,25 @@ def test_error_checking_in_aspell(err, rep, err_aspell, rep_aspell, match):
('dictionary_rare.txt', 'dictionary_usage.txt'),
}

# variable record how many loop executed in case multiple runs of the test, initialize the dictionary
duplicates_dict_num = 0

@pytest.fixture(scope="function")
def initialize_dictionary():
""" initialize the dictionary """
global duplicates_dict_num
duplicates_dict_num += 1
if duplicates_dict_num >= len(_fnames_in_aspell)+1:
global global_err_dicts
global_err_dicts = dict()
global global_pairs
global_pairs = set()
duplicates_dict_num = 1


@fname_params
@pytest.mark.dependency(name='dictionary loop')
@pytest.mark.usefixtures("initialize_dictionary")
def test_dictionary_looping(fname, in_aspell, in_dictionary):
"""Test that all dictionary entries are valid."""
this_err_dict = dict()
Expand Down