Skip to content

Commit

Permalink
fix sentry test
Browse files Browse the repository at this point in the history
  • Loading branch information
Czaki committed Aug 14, 2024
1 parent ce2c1d0 commit 0810987
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions package/tests/test_PartSeg/test_sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ def test_sentry_serialize_clip(monkeypatch):


def test_sentry_variables_clip(monkeypatch):
letters = "abcdefghijklmnoprst"
for letter in letters:
locals()[letter] = 1
try:
raise ValueError("eeee")
except ValueError as ee:
event, hint = sentry_sdk.utils.event_from_exception(ee)

Check warning on line 56 in package/tests/test_PartSeg/test_sentry.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

package/tests/test_PartSeg/test_sentry.py#L56

Unused variable 'hint'
clipped = serialize(event)
assert (
len(clipped["exception"]["values"][0]["stacktrace"]["frames"][0]["vars"])
== sentry_sdk.serializer.MAX_DATABAG_BREADTH
)


def test_sentry_variables_clip_change_breadth(monkeypatch):
monkeypatch.setattr(sentry_sdk.serializer, "MAX_DATABAG_BREADTH", 100)
letters = "abcdefghijklmnoprst"
for letter in letters:
locals()[letter] = 1
Expand All @@ -57,13 +73,10 @@ def test_sentry_variables_clip(monkeypatch):
vars_dict = event["exception"]["values"][0]["stacktrace"]["frames"][0]["vars"]
for letter in letters:
assert letter in vars_dict
clipped = serialize(event)
assert len(clipped["exception"]["values"][0]["stacktrace"]["frames"][0]["vars"]) == 10
monkeypatch.setattr(sentry_sdk.serializer, "MAX_DATABAG_BREADTH", 100)

clipped = serialize(event)
assert len(clipped["exception"]["values"][0]["stacktrace"]["frames"][0]["vars"]) == len(vars_dict)
assert len(clipped["exception"]["values"][0]["stacktrace"]["frames"][0]["vars"]) > 10

client = Client("https://[email protected]/77")
Hub.current.bind_client(client)
sentry_sdk.capture_event(event, hint=hint)
Expand Down

0 comments on commit 0810987

Please sign in to comment.