Skip to content

responses in tests/integrations/stdlib/test_httplib.py does not intercept urlopen requests #1920

@alexmv

Description

@alexmv

How do you use Sentry?

Sentry Saas (sentry.io)

Version

main (1.15.0-16-g2d24560)

Steps to Reproduce

  1. Observe the lack of @responses.activate decorator on test_crumb_capture in tests/integrations/stdlib/test_httplib.py
  2. Apply the following patch:
diff --git a/tests/integrations/stdlib/test_httplib.py b/tests/integrations/stdlib/test_httplib.py
index a66a20c..f1c5dd4 100644
--- a/tests/integrations/stdlib/test_httplib.py
+++ b/tests/integrations/stdlib/test_httplib.py
@@ -31,7 +31,7 @@ from sentry_sdk.integrations.stdlib import StdlibIntegration
 def test_crumb_capture(sentry_init, capture_events):
     sentry_init(integrations=[StdlibIntegration()])

-    url = "http://example.com/"
+    url = "http://example.com/404/"
     responses.add(responses.GET, url, status=200)

     events = capture_events()
  1. pytest tests/integrations/stdlib/test_httplib.py
  2. See the test fails because it's actually talking to the webserver on example.com.

Ref getsentry/responses#373.

Expected Result

Tests mock their network accesses.

Actual Result

Tests require connectivity to http://example.com/ to run

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions