Skip to content

Commit 3f15d02

Browse files
committed
without localhost
1 parent 09dabbf commit 3f15d02

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

tests/unit/conftest.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ def make_httpserver() -> Iterable[HTTPServer]:
1010
werkzeug_logger = getLogger('werkzeug')
1111
werkzeug_logger.disabled = True
1212

13-
server = HTTPServer(threaded=True)
13+
server = HTTPServer(threaded=True, host='127.0.0.1')
1414
server.start()
1515
yield server
1616
server.clear() # type: ignore[no-untyped-call]
1717
if server.is_running():
1818
server.stop() # type: ignore[no-untyped-call]
1919

2020

21-
@pytest.fixture(scope='session')
22-
def httpserver(make_httpserver: HTTPServer) -> HTTPServer:
23-
return make_httpserver
21+
@pytest.fixture
22+
def httpserver(make_httpserver: HTTPServer) -> Iterable[HTTPServer]:
23+
server = make_httpserver
24+
yield server
25+
server.clear() # type: ignore[no-untyped-call]
2426

2527

2628
@pytest.fixture

tests/unit/test_logging.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import asyncio
44
import json
55
import logging
6-
import sys
76
import time
87
from datetime import datetime, timedelta
98
from typing import TYPE_CHECKING
@@ -133,8 +132,6 @@ def generate_logs() -> Iterator[bytes]:
133132
@pytest.fixture
134133
def mock_api(httpserver: HTTPServer) -> None:
135134
"""Set up HTTP server with mocked API endpoints."""
136-
httpserver.clear() # type: ignore[no-untyped-call]
137-
138135
status_generator = StatusResponseGenerator()
139136

140137
# Add actor run status endpoint
@@ -206,7 +203,7 @@ async def test_redirected_logs_async(
206203
with caplog.at_level(logging.DEBUG, logger=logger_name):
207204
async with streamed_log:
208205
# Do stuff while the log from the other Actor is being redirected to the logs.
209-
await asyncio.sleep(4.0 if sys.platform == 'win32' else 2.0)
206+
await asyncio.sleep(1)
210207

211208
# Ensure logs are propagated
212209
assert {(record.message, record.levelno) for record in caplog.records} == set(
@@ -245,7 +242,7 @@ def test_redirected_logs_sync(
245242

246243
with caplog.at_level(logging.DEBUG, logger=logger_name), streamed_log:
247244
# Do stuff while the log from the other Actor is being redirected to the logs.
248-
time.sleep(4.0 if sys.platform == 'win32' else 2.0)
245+
time.sleep(1)
249246

250247
# Ensure logs are propagated
251248
assert {(record.message, record.levelno) for record in caplog.records} == set(
@@ -398,7 +395,7 @@ async def test_redirect_status_message_async(
398395
with caplog.at_level(logging.DEBUG, logger=logger_name):
399396
async with status_message_redirector:
400397
# Do stuff while the status from the other Actor is being redirected to the logs.
401-
await asyncio.sleep(3)
398+
await asyncio.sleep(1)
402399

403400
assert caplog.records[0].message == 'Status: RUNNING, Message: Initial message'
404401
assert caplog.records[1].message == 'Status: RUNNING, Message: Another message'
@@ -422,7 +419,7 @@ def test_redirect_status_message_sync(
422419
status_message_redirector = run_client.get_status_message_watcher(check_period=timedelta(seconds=0))
423420
with caplog.at_level(logging.DEBUG, logger=logger_name), status_message_redirector:
424421
# Do stuff while the status from the other Actor is being redirected to the logs.
425-
time.sleep(3)
422+
time.sleep(1)
426423

427424
assert caplog.records[0].message == 'Status: RUNNING, Message: Initial message'
428425
assert caplog.records[1].message == 'Status: RUNNING, Message: Another message'

0 commit comments

Comments
 (0)