1414
1515from ...opentracer .utils import init_tracer
1616from ...base import BaseTracerTestCase
17+ from ...utils import assert_span_http_status_code
1718
1819
1920class PyramidBase (BaseTracerTestCase ):
@@ -65,7 +66,7 @@ def test_200(self, query_string=''):
6566 assert s .error == 0
6667 assert s .span_type == 'web'
6768 assert s .meta .get ('http.method' ) == 'GET'
68- assert s . metrics . get ( 'http.status_code' ) == 200
69+ assert_span_http_status_code ( s , 200 )
6970 assert s .meta .get (http .URL ) == 'http://localhost/'
7071 if config .pyramid .trace_query_string :
7172 assert s .meta .get (http .QUERY_STRING ) == query_string
@@ -154,7 +155,7 @@ def test_404(self):
154155 assert s .error == 0
155156 assert s .span_type == 'web'
156157 assert s .meta .get ('http.method' ) == 'GET'
157- assert s . metrics . get ( 'http.status_code' ) == 404
158+ assert_span_http_status_code ( s , 404 )
158159 assert s .meta .get (http .URL ) == 'http://localhost/404'
159160
160161 def test_302 (self ):
@@ -169,7 +170,7 @@ def test_302(self):
169170 assert s .error == 0
170171 assert s .span_type == 'web'
171172 assert s .meta .get ('http.method' ) == 'GET'
172- assert s . metrics . get ( 'http.status_code' ) == 302
173+ assert_span_http_status_code ( s , 302 )
173174 assert s .meta .get (http .URL ) == 'http://localhost/redirect'
174175
175176 def test_204 (self ):
@@ -184,7 +185,7 @@ def test_204(self):
184185 assert s .error == 0
185186 assert s .span_type == 'web'
186187 assert s .meta .get ('http.method' ) == 'GET'
187- assert s . metrics . get ( 'http.status_code' ) == 204
188+ assert_span_http_status_code ( s , 204 )
188189 assert s .meta .get (http .URL ) == 'http://localhost/nocontent'
189190
190191 def test_exception (self ):
@@ -202,7 +203,7 @@ def test_exception(self):
202203 assert s .error == 1
203204 assert s .span_type == 'web'
204205 assert s .meta .get ('http.method' ) == 'GET'
205- assert s . metrics . get ( 'http.status_code' ) == 500
206+ assert_span_http_status_code ( s , 500 )
206207 assert s .meta .get (http .URL ) == 'http://localhost/exception'
207208 assert s .meta .get ('pyramid.route.name' ) == 'exception'
208209
@@ -218,7 +219,7 @@ def test_500(self):
218219 assert s .error == 1
219220 assert s .span_type == 'web'
220221 assert s .meta .get ('http.method' ) == 'GET'
221- assert s . metrics . get ( 'http.status_code' ) == 500
222+ assert_span_http_status_code ( s , 500 )
222223 assert s .meta .get (http .URL ) == 'http://localhost/error'
223224 assert s .meta .get ('pyramid.route.name' ) == 'error'
224225 assert type (s .error ) == int
@@ -238,7 +239,7 @@ def test_json(self):
238239 assert s .error == 0
239240 assert s .span_type == 'web'
240241 assert s .meta .get ('http.method' ) == 'GET'
241- assert s . metrics . get ( 'http.status_code' ) == 200
242+ assert_span_http_status_code ( s , 200 )
242243 assert s .meta .get (http .URL ) == 'http://localhost/json'
243244 assert s .meta .get ('pyramid.route.name' ) == 'json'
244245
@@ -262,7 +263,7 @@ def test_renderer(self):
262263 assert s .error == 0
263264 assert s .span_type == 'web'
264265 assert s .meta .get ('http.method' ) == 'GET'
265- assert s . metrics . get ( 'http.status_code' ) == 200
266+ assert_span_http_status_code ( s , 200 )
266267 assert s .meta .get (http .URL ) == 'http://localhost/renderer'
267268 assert s .meta .get ('pyramid.route.name' ) == 'renderer'
268269
@@ -284,7 +285,7 @@ def test_http_exception_response(self):
284285 assert s .error == 1
285286 assert s .span_type == 'web'
286287 assert s .meta .get ('http.method' ) == 'GET'
287- assert s . metrics . get ( 'http.status_code' ) == 404
288+ assert_span_http_status_code ( s , 404 )
288289 assert s .meta .get (http .URL ) == 'http://localhost/404/raise_exception'
289290
290291 def test_insert_tween_if_needed_already_set (self ):
@@ -356,6 +357,6 @@ def test_200_ot(self):
356357 assert dd_span .error == 0
357358 assert dd_span .span_type == 'web'
358359 assert dd_span .meta .get ('http.method' ) == 'GET'
359- assert dd_span . metrics . get ( 'http.status_code' ) == 200
360+ assert_span_http_status_code ( dd_span , 200 )
360361 assert dd_span .meta .get (http .URL ) == 'http://localhost/'
361362 assert dd_span .meta .get ('pyramid.route.name' ) == 'index'
0 commit comments