Skip to content

Commit

Permalink
fix: ensure tests always assert same values
Browse files Browse the repository at this point in the history
  • Loading branch information
PrinceEGY committed Jan 6, 2025
1 parent a8654d7 commit 05768e1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
2 changes: 1 addition & 1 deletion tests/test_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions tests/test_headset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 05768e1

Please sign in to comment.