Skip to content

Commit

Permalink
Improve error validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
a-feld committed Aug 14, 2019
1 parent 139e7d3 commit bc6fed8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions integrations/opentelemetry-wsgi/tests/test_wsgi_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def start_response(self, status, response_headers, exc_info=None):
self.exc_info = exc_info
return self.write

def validate_response(self, response, error=False):
def validate_response(self, response, error=None):
try:
value = next(response)
self.span_context_manager.__exit__.assert_not_called()
Expand All @@ -101,8 +101,9 @@ def validate_response(self, response, error=False):
self.assertEqual(self.status, "200 OK")
self.assertEqual(self.response_headers, [("Content-Type", "text/plain")])
if error:
self.assertIsNotNone(self.exc_info)
self.assertIs(self.exc_info[0], ValueError)
self.assertIs(self.exc_info[0], error)
self.assertIsInstance(self.exc_info[1], error)
self.assertIsNotNone(self.exc_info[2])
else:
self.assertIsNone(self.exc_info)

Expand All @@ -124,7 +125,7 @@ def test_wsgi_iterable(self):
def test_wsgi_exc_info(self):
app = OpenTelemetryMiddleware(error_wsgi)
response = app(self.environ, self.start_response)
self.validate_response(response, error=True)
self.validate_response(response, error=ValueError)


if __name__ == "__main__":
Expand Down

0 comments on commit bc6fed8

Please sign in to comment.