8000 Add tests · getsentry/sentry-python@cf3cc22 · GitHub
[go: up one dir, main page]

Skip to content

Commit cf3cc22

Browse files
committed
Add tests
1 parent e61b1e7 commit cf3cc22

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

tests/test_utils.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import pytest
22
import re
3+
import sys
34

4-
from sentry_sdk.utils import is_valid_sample_rate, logger, parse_url, sanitize_url
5+
from sentry_sdk.utils import (
6+
is_valid_sample_rate,
7+
logger,
8+
parse_url,
9+
sanitize_url,
10+
serialize_frame,
11+
)
512

613
try:
714
from unittest import mock # python 3.3 and above
@@ -221,3 +228,21 @@ def test_warns_on_invalid_sample_rate(rate, StringContaining): # noqa: N803
221228
result = is_valid_sample_rate(rate, source="Testing")
222229
logger.warning.assert_any_call(StringContaining("Given sample rate is invalid"))
223230
assert result is False
231+
232+
233+
def test_include_source_context_when_serializing_frame():
234+
frame = sys._getframe()
235+
result = serialize_frame(frame)
236+
237+
assert "pre_context" in result
238+
assert "context_line" in result
239+
assert "post_context" in result
240+
241+
242+
def test_exclude_source_context_when_serializing_frame():
243+
frame = sys._getframe()
244+
result = serialize_frame(frame, include_source_context=False)
245+
246+
assert "pre_context" not in result
247+
assert "context_line" not in result
248+
assert "post_context" not in result

0 commit comments

Comments
 (0)
0