Skip to content

Commit 743a073

Browse files
committed
update tests: enhance wait_for_boot timeout logic and improve test reliability
- Adjust `time.time` mocking to provide sufficient values for all test cases, ensuring proper timeout simulation. - Include `stdout` in `Mock` return values for better output validation. - Maintain timeout behavior assertion to confirm expected results.
1 parent 2aeea66 commit 743a073

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tests/helpers/test_emulator_helper.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,12 @@ def test_wait_for_boot_adb_failure(self):
197197
with patch("pathlib.Path.exists", return_value=True):
198198
with patch("subprocess.run") as mock_run:
199199
# Simulate adb failure - keep returning error
200-
mock_run.return_value = Mock(returncode=1)
200+
mock_run.return_value = Mock(returncode=1, stdout="")
201201

202202
with patch("time.sleep"): # Speed up test
203-
with patch("time.time", side_effect=[0, 1, 2, 3, 400]): # Simulate timeout
203+
# Provide enough time values for all calls, then jump to timeout
204+
time_values = list(range(0, 20)) + [400] * 10 # Provide plenty of values
205+
with patch("time.time", side_effect=time_values): # Simulate timeout
204206
result = wait_for_boot(timeout=10)
205207

206208
assert result is False # Should return False on timeout

0 commit comments

Comments
 (0)