Skip to content

Commit 1430a0d

Browse files
committed
Address Copilot comments (3)
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
1 parent 66b0934 commit 1430a0d

4 files changed

Lines changed: 22 additions & 5 deletions

File tree

tests/integration/conftest.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
import subprocess
33
import tempfile
44
import time
5+
from contextlib import contextmanager
56
from pathlib import Path
6-
from typing import Any, Generator
7+
from typing import Any, Generator, Iterator
78

89
import pytest
910

@@ -113,6 +114,17 @@ def cleanup(self) -> None:
113114
self._log_files.clear()
114115

115116

117+
@contextmanager
118+
def _preserve_http_port() -> Iterator[None]:
119+
# start_sidecar() mutates settings.DAPR_HTTP_PORT.
120+
# This restores the original value so it does not leak across test modules.
121+
original = settings.DAPR_HTTP_PORT
122+
try:
123+
yield
124+
finally:
125+
settings.DAPR_HTTP_PORT = original
126+
127+
116128
@pytest.fixture(scope='module')
117129
def dapr_env() -> Generator[DaprTestEnvironment, Any, None]:
118130
"""Provides a DaprTestEnvironment for programmatic SDK testing.
@@ -121,9 +133,12 @@ def dapr_env() -> Generator[DaprTestEnvironment, Any, None]:
121133
avoiding port conflicts from rapid start/stop cycles and cutting total
122134
test time significantly.
123135
"""
124-
env = DaprTestEnvironment()
125-
yield env
126-
env.cleanup()
136+
with _preserve_http_port():
137+
env = DaprTestEnvironment()
138+
try:
139+
yield env
140+
finally:
141+
env.cleanup()
127142

128143

129144
@pytest.fixture(scope='module')

tests/integration/test_configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def _redis_set(key: str, value: str, version: int = 1) -> None:
1919
args=('docker', 'exec', REDIS_CONTAINER, 'redis-cli', 'SET', key, f'{value}||{version}'),
2020
check=True,
2121
capture_output=True,
22+
timeout=10,
2223
)
2324

2425

tests/integration/test_pubsub.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def _flush_redis() -> None:
2323
args=('docker', 'exec', REDIS_CONTAINER, 'redis-cli', 'FLUSHDB'),
2424
check=True,
2525
capture_output=True,
26+
timeout=10,
2627
)
2728

2829

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ commands =
5151
allowlist_externals=*
5252

5353
commands_pre =
54-
pip uninstall -y dapr dapr-ext-grpc dapr-ext-fastapi dapr-ext-langgraph dapr-ext-strands dapr-ext-flask dapr-ext-langgraph dapr-ext-strands
54+
pip uninstall -y dapr dapr-ext-grpc dapr-ext-fastapi dapr-ext-langgraph dapr-ext-strands dapr-ext-flask
5555
pip install -r {toxinidir}/dev-requirements.txt \
5656
-e {toxinidir}/ \
5757
-e {toxinidir}/ext/dapr-ext-workflow/ \

0 commit comments

Comments
 (0)