4
4
5
5
from werkzeug .test import Client
6
6
from django .core .management import execute_from_command_line
7
+ from django .db .utils import OperationalError
7
8
8
9
9
10
try :
@@ -134,7 +135,7 @@ def test_sql_queries(sentry_init, capture_events):
134
135
sql = connection .cursor ()
135
136
136
137
events = capture_events ()
137
- with pytest .raises (Exception ):
138
+ with pytest .raises (OperationalError ):
138
139
# table doesn't even exist
139
140
sql .execute ("""SELECT count(*) FROM people_person WHERE foo = %s""" , [123 ])
140
141
@@ -155,7 +156,7 @@ def test_sql_dict_query_params(sentry_init, capture_events):
155
156
sql = connection .cursor ()
156
157
157
158
events = capture_events ()
158
- with pytest .raises (Exception ):
159
+ with pytest .raises (OperationalError ):
159
160
# table doesn't even exist
160
161
sql .execute (
161
162
"""SELECT count(*) FROM people_person WHERE foo = %(my_foo)s""" ,
@@ -182,8 +183,8 @@ def test_sql_psycopg2_string_composition(sentry_init, capture_events):
182
183
sql = connection .cursor ()
183
184
184
185
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
187
188
sql .execute (
188
189
psycopg2_sql .SQL ("SELECT %(my_param)s FROM people_person" ), {"my_param" : 10 }
189
190
)
@@ -204,7 +205,7 @@ def test_sql_queries_large_params(sentry_init, capture_events):
204
205
sql = connection .cursor ()
205
206
206
207
events = capture_events ()
207
- with pytest .raises (Exception ):
208
+ with pytest .raises (OperationalError ):
208
209
# table doesn't even exist
209
210
sql .execute (
210
211
"""SELECT count(*) FROM people_person WHERE foo = %s""" , ["x" * 1000 ]
0 commit comments