Skip to content

Commit c3dd90f

Browse files
fixup! Add timeout to auth/aio tests
1 parent fb13488 commit c3dd90f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

test/auth/aio/authorization_test_helper.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,24 @@ async def connect_and_provide_credentials(
7878
import asyncio
7979

8080
try:
81-
# Use asyncio task for connection instead of thread
81+
# Start connection task
8282
connect_task = asyncio.create_task(self.connect_and_execute_simple_query())
8383

8484
if self.auth_test_env == "docker":
85+
# Give the connection task a chance to start and open the browser
86+
# before starting browser automation. This is critical because
87+
# create_task() only schedules the task - it doesn't run until we yield.
88+
await asyncio.sleep(0) # Yield to let connect_task start
89+
await asyncio.sleep(2) # Give connection time to open browser
90+
8591
# Browser credentials still needs to run in thread since it's sync
8692
browser = threading.Thread(
8793
target=self._provide_credentials, args=(scenario, login, password)
8894
)
8995
browser.start()
9096
# Wait for browser thread to complete
91-
await asyncio.get_event_loop().run_in_executor(None, browser.join)
97+
loop = asyncio.get_running_loop()
98+
await loop.run_in_executor(None, browser.join)
9299

93100
# Wait for connection task to complete
94101
await connect_task

test/auth/aio/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
def pytest_collection_modifyitems(items) -> None:
2020
"""Apply default timeout to all tests in this directory."""
2121
for item in items:
22-
# Only add timeout if not already set
22+
# Apply timeout if not already set
2323
if not any(mark.name == "timeout" for mark in item.iter_markers()):
2424
item.add_marker(pytest.mark.timeout(DEFAULT_AUTH_TEST_TIMEOUT))

0 commit comments

Comments
 (0)