Skip to content

Commit

Permalink
fix: Fix some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
untitaker committed Oct 2, 2019
1 parent 60049e8 commit 22800e3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
2 changes: 2 additions & 0 deletions sentry_sdk/hub.py
Expand Up @@ -301,6 +301,8 @@ def bind_client(
"""Binds a new client to the hub."""
top = self._stack[-1]
self._stack[-1] = (new, top[1])
if not new or new.options["_experiments"].get("fast_serialize", False):
top[1].clear_breadcrumbs()

def capture_event(
self,
Expand Down
1 change: 0 additions & 1 deletion sentry_sdk/integrations/stdlib.py
Expand Up @@ -108,7 +108,6 @@ def getresponse(self, *args, **kwargs):
rv = real_getresponse(self, *args, **kwargs)

if data_dict is not None:
data_dict["httplib_response"] = rv
data_dict["status_code"] = rv.status
data_dict["reason"] = rv.reason
except TypeError:
Expand Down
8 changes: 1 addition & 7 deletions sentry_sdk/tracing.py
Expand Up @@ -460,17 +460,11 @@ def _maybe_create_breadcrumbs_from_span(hub, span):
message=span.description, type="redis", category="redis", data=span._tags
)
elif span.op == "http" and span.is_success():
hub.add_breadcrumb(
type="http",
category="httplib",
data=span._data,
hint={"httplib_response": span._data.pop("httplib_response", None)},
)
hub.add_breadcrumb(type="http", category="httplib", data=span._data)
elif span.op == "subprocess":
hub.add_breadcrumb(
type="subprocess",
category="subprocess",
message=span.description,
data=span._data,
hint={"popen_instance": span._data.pop("popen_instance", None)},
)
5 changes: 1 addition & 4 deletions tests/integrations/stdlib/test_httplib.py
Expand Up @@ -40,10 +40,7 @@ def test_crumb_capture(sentry_init, capture_events):

def test_crumb_capture_hint(sentry_init, capture_events):
def before_breadcrumb(crumb, hint):
if "httplib_response" in hint:
con = hint["httplib_response"].getheader("Connection")
assert con.lower() == "close"
crumb["data"]["extra"] = "foo"
crumb["data"]["extra"] = "foo"
return crumb

sentry_init(integrations=[StdlibIntegration()], before_breadcrumb=before_breadcrumb)
Expand Down
7 changes: 6 additions & 1 deletion tests/integrations/stdlib/test_subprocess.py
Expand Up @@ -55,6 +55,7 @@ def test_subprocess_basic(
iterator,
env_mapping,
with_cwd,
fast_serialize,
):
monkeypatch.setenv("FOO", "bar")

Expand Down Expand Up @@ -122,7 +123,11 @@ def test_subprocess_basic(

assert message_event["message"] == "hi"

data = {"subprocess.cwd": os.getcwd()} if with_cwd else {}
if fast_serialize:
data = {"subprocess.cwd": os.getcwd() if with_cwd else None}
else:
data = {"subprocess.cwd": os.getcwd()} if with_cwd else {}

crumb, = message_event["breadcrumbs"]
assert crumb == {
"category": "subprocess",
Expand Down

0 comments on commit 22800e3

Please sign in to comment.