Skip to content

Commit

Permalink
Merge pull request #530 from lleontop/fix_ignore_duplicates_modules
Browse files Browse the repository at this point in the history
Ignore duplicate modules in ignore list
  • Loading branch information
bblommers authored Mar 2, 2024
2 parents 10924ba + b5a42db commit 4225fba
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion freezegun/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def configure(default_ignore_list: Optional[List[str]]=None, extend_ignore_list:
if default_ignore_list:
settings.default_ignore_list = default_ignore_list
if extend_ignore_list:
settings.default_ignore_list = [*settings.default_ignore_list, *extend_ignore_list]
settings.default_ignore_list = list(dict.fromkeys([*settings.default_ignore_list, *extend_ignore_list]))


def reset_config() -> None:
Expand Down
37 changes: 37 additions & 0 deletions tests/test_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,40 @@ def test_extend_default_ignore_list():
auto_tick_seconds=0,
real_asyncio=False,
)

def test_extend_default_ignore_list_duplicate_items():
freezegun.configure(extend_ignore_list=['tensorflow', 'pymongo', 'tensorflow','rabbitmq'])
freezegun.configure(extend_ignore_list=['tensorflow'])

with mock.patch("freezegun.api._freeze_time.__init__", return_value=None) as _freeze_time_init_mock:

freezegun.freeze_time("2020-10-06")

expected_ignore_list = [
'nose.plugins',
'six.moves',
'django.utils.six.moves',
'google.gax',
'threading',
'multiprocessing',
'queue',
'selenium',
'_pytest.terminal.',
'_pytest.runner.',
'gi',
'prompt_toolkit',
'tensorflow',
'pymongo',
'rabbitmq',
]

_freeze_time_init_mock.assert_called_once_with(
time_to_freeze_str="2020-10-06",
tz_offset=0,
ignore=expected_ignore_list,
tick=False,
as_arg=False,
as_kwarg='',
auto_tick_seconds=0,
real_asyncio=False,
)

0 comments on commit 4225fba

Please sign in to comment.