Skip to content

Commit 0f5e153

Browse files
committed
ref: Tighten exception constraints
1 parent bba8d4f commit 0f5e153

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tests/integrations/django/test_basic.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from werkzeug.test import Client
66
from django.core.management import execute_from_command_line
7+
from django.db.utils import OperationalError
78

89

910
try:
@@ -134,7 +135,7 @@ def test_sql_queries(sentry_init, capture_events):
134135
sql = connection.cursor()
135136

136137
events = capture_events()
137-
with pytest.raises(Exception):
138+
with pytest.raises(OperationalError):
138139
# table doesn't even exist
139140
sql.execute("""SELECT count(*) FROM people_person WHERE foo = %s""", [123])
140141

@@ -155,7 +156,7 @@ def test_sql_dict_query_params(sentry_init, capture_events):
155156
sql = connection.cursor()
156157

157158
events = capture_events()
158-
with pytest.raises(Exception):
159+
with pytest.raises(OperationalError):
159160
# table doesn't even exist
160161
sql.execute(
161162
"""SELECT count(*) FROM people_person WHERE foo = %(my_foo)s""",
@@ -182,8 +183,8 @@ def test_sql_psycopg2_string_composition(sentry_init, capture_events):
182183
sql = connection.cursor()
183184

184185
events = capture_events()
185-
with pytest.raises(Exception):
186-
# table doesn't even exist
186+
with pytest.raises(TypeError):
187+
# crashes because we use sqlite
187188
sql.execute(
188189
psycopg2_sql.SQL("SELECT %(my_param)s FROM people_person"), {"my_param": 10}
189190
)
@@ -204,7 +205,7 @@ def test_sql_queries_large_params(sentry_init, capture_events):
204205
sql = connection.cursor()
205206

206207
events = capture_events()
207-
with pytest.raises(Exception):
208+
with pytest.raises(OperationalError):
208209
# table doesn't even exist
209210
sql.execute(
210211
"""SELECT count(*) FROM people_person WHERE foo = %s""", ["x" * 1000]

0 commit comments

Comments
 (0)