MCPcopy
hub / github.com/PostHog/posthog / simulate_postgres_error

Function simulate_postgres_error

posthog/test/test_health.py:212–219  ·  view source on GitHub ↗

Causes any call to cursor to raise the upper most Error in djangos db Exception hierachy

()

Source from the content-addressed store, hash-verified

210
211@contextmanager
212def simulate_postgres_error():
213 """
214 Causes any call to cursor to raise the upper most Error in djangos db
215 Exception hierachy
216 """
217 with patch.object(connections[DEFAULT_DB_ALIAS], "cursor") as cursor_mock:
218 cursor_mock.side_effect = DjangoDatabaseError # This should be the most general
219 yield
220
221
222@contextmanager

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…