@@ -1164,7 +1164,7 @@ def test_tracing_middleware_uses_test_client(client, django_elasticapm_client):
11641164 {'capture_body' : 'off' },
11651165], indirect = True )
11661166def test_capture_post_errors_dict (client , django_elasticapm_client ):
1167- with pytest .raises (Exception ):
1167+ with pytest .raises (MyException ):
11681168 client .post (reverse ('elasticapm-raise-exc' ), {'username' : 'john' , 'password' : 'smith' })
11691169 error = django_elasticapm_client .events [0 ]
11701170 if django_elasticapm_client .config .capture_body in ('errors' , 'all' ):
@@ -1180,7 +1180,7 @@ def test_capture_post_errors_dict(client, django_elasticapm_client):
11801180 {'capture_body' : 'off' },
11811181], indirect = True )
11821182def test_capture_post_errors_multivalue_dict (client , django_elasticapm_client ):
1183- with pytest .raises (Exception ):
1183+ with pytest .raises (MyException ):
11841184 client .post (reverse ('elasticapm-raise-exc' ), 'key=value1&key=value2&test=test&key=value3' ,
11851185 content_type = 'application/x-www-form-urlencoded' )
11861186 error = django_elasticapm_client .events [0 ]
@@ -1200,9 +1200,9 @@ def test_capture_post_errors_multivalue_dict(client, django_elasticapm_client):
12001200], indirect = True )
12011201def test_capture_post_errors_raw (client , django_sending_elasticapm_client ):
12021202 # use "sending" client to ensure that we encode the payload correctly
1203- with pytest .raises (Exception ):
1204- client .post (reverse ('elasticapm-raise-exc' ), json .dumps ({'a' : 'b' }). encode ( 'utf8' ) ,
1205- content_type = 'application/json' )
1203+ with pytest .raises (MyException ):
1204+ client .post (reverse ('elasticapm-raise-exc' ), json .dumps ({'a' : 'b' }),
1205+ content_type = 'application/json; charset=utf8 ' )
12061206 error = django_sending_elasticapm_client .httpserver .payloads [0 ]
12071207 if django_sending_elasticapm_client .config .capture_body in ('errors' , 'all' ):
12081208 assert error ['errors' ][0 ]['context' ]['request' ]['body' ] == '{"a": "b"}'
@@ -1217,7 +1217,7 @@ def test_capture_post_errors_raw(client, django_sending_elasticapm_client):
12171217 {'capture_body' : 'off' },
12181218], indirect = True )
12191219def test_capture_empty_body (client , django_elasticapm_client ):
1220- with pytest .raises (Exception ):
1220+ with pytest .raises (MyException ):
12211221 client .post (reverse ('elasticapm-raise-exc' ), data = {})
12221222 error = django_elasticapm_client .events [0 ]
12231223 # body should be empty no matter if we capture it or not
0 commit comments