From 05768e12d7d84b54fc11f8c3102b00ecc5fd1626 Mon Sep 17 00:00:00 2001 From: Ahmed Mohsen Date: Mon, 6 Jan 2025 23:46:42 +0200 Subject: [PATCH] fix: ensure tests always assert same values --- pyproject.toml | 7 +++++-- tests/test_connector.py | 2 +- tests/test_headset.py | 10 +++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index eb16146..f474bb4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,9 @@ license = { text = "MIT" } authors = [{ name = "Ahmed Mohsen", email = "ahmed25004@hotmail.com" }] classifiers = [ "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python", "Operating System :: OS Independent", "Intended Audience :: Science/Research", @@ -39,4 +41,5 @@ Homepage = "https://github.com/PrinceEGY/pymindwave2" Issues = "https://github.com/PrinceEGY/pymindwave2/issues" [tool.pytest.ini_options] -timeout = 60 +timeout = 300 +asyncio_default_fixture_loop_scope = "session" diff --git a/tests/test_connector.py b/tests/test_connector.py index ed82483..7983a25 100644 --- a/tests/test_connector.py +++ b/tests/test_connector.py @@ -39,7 +39,7 @@ async def test_connect_failure(mocker): assert tg_connector.st_writer is None -@pytest.mark.asyncio(loop_scope="session")(loop_scope="session") +@pytest.mark.asyncio(loop_scope="session") async def test_connect_already_connected(mocker): tg_connector = ThinkGearConnector() mock_reader = mocker.AsyncMock() diff --git a/tests/test_headset.py b/tests/test_headset.py index 765de79..5a3cddd 100644 --- a/tests/test_headset.py +++ b/tests/test_headset.py @@ -56,16 +56,16 @@ def test_stop_device(mock_tg_connector): def test_multiple_start_attempts(mock_tg_connector, mocker): SingletonMeta._instances = {} - tg_connector = mock_tg_connector(scan_count=15, scan_sleep_duration=0.2) + tg_connector = mock_tg_connector(scan_count=50, scan_sleep_duration=0.2) headset = MindWaveMobile2(tg_connector=tg_connector) mock_callback = mocker.Mock() headset.on_timeout(mock_callback) - value = headset.start(timeout=1, n_tries=4) - assert value is True - assert headset.is_running is True - assert mock_callback.call_count == 3 + value = headset.start(timeout=1, n_tries=5) + assert value is False + assert headset.is_running is False + assert mock_callback.call_count == 5 # cleanup headset.stop()