test(be): every dependency override goes through override_dep

22 test files set `app.dependency_overrides[...]` by hand and tore down with a blanket `.clear()`
in a `finally`, which wipes every override rather than the test's own and stops fixtures composing.
They now take the `override_dep` fixture (helpers get it passed in), whose teardown restores each
key's prior value; no clear() carried meaning between two phases of a test. A convention test fails
any test file that writes `dependency_overrides` directly.
This commit is contained in:
2026-09-19 17:26:07 +02:00
parent dc902d2c0e
commit 8759b5860d
23 changed files with 537 additions and 529 deletions
+3 -6
View File
@@ -62,14 +62,11 @@ def sessions(monkeypatch):
@pytest.fixture
def client(monkeypatch):
def client(monkeypatch, override_dep):
monkeypatch.setattr(state, "_configured_cache", True)
user = User(id=VIEWER, email="hls@example.com")
app.dependency_overrides[current_user] = lambda: user
try:
yield TestClient(app)
finally:
app.dependency_overrides.pop(current_user, None)
override_dep(current_user, lambda: user)
return TestClient(app)
def test_a_segment_is_served_from_the_session_the_url_names(client, tmp_path, sessions):