Skip to content

Commit

Permalink
Fix tests and mypy dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan GAYVALLET <[email protected]>
  • Loading branch information
Meallia committed Nov 12, 2024
1 parent a69dae0 commit 0a34d52
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[pytest]
asyncio_mode = auto
asyncio_default_fixture_loop_scope = function
addopts =
--strict-markers
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ pytest-asyncio
pytest-cov
pytest-mock
pytest-timeout
types-pkg_resources
types-setuptools
types-PyYAML
6 changes: 5 additions & 1 deletion tests/peering/test_keepalive.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import pytest

from kopf._core.engines.peering import keepalive
from itertools import chain, repeat
from unittest import mock


class StopInfiniteCycleException(Exception):
Expand All @@ -11,7 +13,9 @@ async def test_background_task_runs(mocker, settings, namespaced_peering_resourc
touch_mock = mocker.patch('kopf._core.engines.peering.touch')

sleep_mock = mocker.patch('asyncio.sleep')
sleep_mock.side_effect = [None, None, StopInfiniteCycleException]
# restore the default behavior after exhausting test values.
# pytest-aiohttp calls asyncio.sleep during teardown, before the mock is removed.
sleep_mock.side_effect = chain([None, None, StopInfiniteCycleException], repeat(mock.DEFAULT))

randint_mock = mocker.patch('random.randint')
randint_mock.side_effect = [7, 5, 9]
Expand Down

0 comments on commit 0a34d52

Please sign in to comment.