Refactor: apply pyformat for coding style consistency

add pyformat for presubmit hook

Flag: EXEMPT mainline
Bug: 419423721
Test: atest CtsConnectivityMultiDevicesTestCases
Change-Id: I9abc5cee454e8c8e21ce7e3c134145857680251f
This commit is contained in:
Jimi Chen 2025-05-28 09:33:18 +00:00
commit dcbe9b403d

View file

@ -19,9 +19,11 @@ from typing import Callable
class UnexpectedBehaviorError(Exception):
"""Raised when there is an unexpected behavior during applying a procedure."""
class UnexpectedExceptionError(Exception):
"""Raised when there is an unexpected exception throws during applying a procedure"""
def expect_with_retry(
predicate: Callable[[], bool],
retry_action: Callable[[], None] = None,
@ -41,19 +43,20 @@ def expect_with_retry(
time.sleep(retry_interval_sec)
raise UnexpectedBehaviorError(
"Predicate didn't become true after " + str(max_retries) + " retries."
"Predicate didn't become true after " + str(max_retries) + ' retries.'
)
def expect_throws(runnable: callable, exception_class) -> None:
try:
runnable()
raise UnexpectedBehaviorError("Expected an exception, but none was thrown")
raise UnexpectedBehaviorError('Expected an exception, but none was thrown')
except exception_class:
pass
except UnexpectedBehaviorError as e:
raise e
except Exception as e:
raise UnexpectedExceptionError(
f"Expected exception of type {exception_class.__name__}, "
f"but got {type(e).__name__}: {e}"
)
raise UnexpectedExceptionError(
f'Expected exception of type {exception_class.__name__}, '
f'but got {type(e).__name__}: {e}'
)