test(profiles): allow reentrant env lock

This commit is contained in:
starship-s committed 2026-05-15 03:09:16 -06:00
1 parent aa1c7c24f4
commit f38c70415f
1 file changed
+11 -4
+11 -4
View File
@@ -712,11 +712,18 @@ class TestSSRFCheck:
class TestENVLock:
def test_env_lock_importable_from_streaming(self):
"""_ENV_LOCK must be importable from api.streaming."""
"""_ENV_LOCK must be an importable threading-style reentrant lock."""
from api.streaming import _ENV_LOCK
import threading
assert isinstance(_ENV_LOCK, type(threading.Lock())), \
"_ENV_LOCK must be a threading.Lock"
assert hasattr(_ENV_LOCK, "acquire"), "_ENV_LOCK must expose acquire()"
assert hasattr(_ENV_LOCK, "release"), "_ENV_LOCK must expose release()"
assert hasattr(_ENV_LOCK, "__enter__"), "_ENV_LOCK must support context manager use"
assert hasattr(_ENV_LOCK, "__exit__"), "_ENV_LOCK must support context manager use"
with _ENV_LOCK:
acquired = _ENV_LOCK.acquire(False)
assert acquired, "_ENV_LOCK must allow reentrant acquisition"
_ENV_LOCK.release()
def test_env_lock_importable_in_routes(self):
"""api.routes must be able to import _ENV_LOCK from api.streaming."""