From a015f9797d851d91718c996c90e87e2f7feb0ba0 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Fri, 26 May 2023 13:02:18 +0200 Subject: [PATCH 01/38] Fix UnicodeEncodeError on 2.7 --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 62aa5250b4..929def024a 100644 --- a/tox.ini +++ b/tox.ini @@ -440,6 +440,7 @@ deps = trytond-v{4.6,4.8,5.0,5.2,5.4}: werkzeug<2.0 setenv = + LC_ALL=en_US.UTF-8 PYTHONDONTWRITEBYTECODE=1 common: TESTPATH=tests aiohttp: TESTPATH=tests/integrations/aiohttp From 561f4ba2511b9b8388a350490c8e597b34ca46d7 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Fri, 26 May 2023 13:07:37 +0200 Subject: [PATCH 02/38] attempt --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 929def024a..c00991c6a0 100644 --- a/tox.ini +++ b/tox.ini @@ -441,6 +441,7 @@ deps = setenv = LC_ALL=en_US.UTF-8 + LANG=en_US.UTF-8 PYTHONDONTWRITEBYTECODE=1 common: TESTPATH=tests aiohttp: TESTPATH=tests/integrations/aiohttp From 22ab0c41fa8a591e941cbb9b02ed47ca67279e45 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 10:32:17 +0200 Subject: [PATCH 03/38] fail a test explicitly --- tests/test_basics.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_basics.py b/tests/test_basics.py index 751b0a617b..d28511ac74 100644 --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -74,6 +74,8 @@ def test_event_id(sentry_init, capture_events): sentry_init() events = capture_events() + assert False # XXX for testing the ci + try: raise ValueError("aha!") except Exception: From c279ef1bf75c0e32119531f4dcff8b0f704e2972 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 11:28:42 +0200 Subject: [PATCH 04/38] Do not encode cached value to determine size (#2143) --- sentry_sdk/integrations/django/caching.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry_sdk/integrations/django/caching.py b/sentry_sdk/integrations/django/caching.py index affbae3226..921f8e485d 100644 --- a/sentry_sdk/integrations/django/caching.py +++ b/sentry_sdk/integrations/django/caching.py @@ -51,7 +51,7 @@ def _instrument_call(cache, method_name, original_method, args, kwargs): if value: span.set_data(SPANDATA.CACHE_HIT, True) - size = len(text_type(value).encode("utf-8")) + size = len(text_type(value)) span.set_data(SPANDATA.CACHE_ITEM_SIZE, size) else: From 5be026ce33cb3839d5720cdc9c46ce9291f0ba06 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 12:33:10 +0200 Subject: [PATCH 05/38] . --- .github/workflows/test-common.yml | 2 ++ tox.ini | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-common.yml b/.github/workflows/test-common.yml index 46aec35dd4..eed9890bb6 100644 --- a/.github/workflows/test-common.yml +++ b/.github/workflows/test-common.yml @@ -59,6 +59,8 @@ jobs: set -x # print commands that are executed coverage erase + locale + # Run tests ./scripts/runtox.sh "py${{ matrix.python-version }}-common" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch && coverage combine .coverage* && diff --git a/tox.ini b/tox.ini index c00991c6a0..f336e775f0 100644 --- a/tox.ini +++ b/tox.ini @@ -440,8 +440,8 @@ deps = trytond-v{4.6,4.8,5.0,5.2,5.4}: werkzeug<2.0 setenv = - LC_ALL=en_US.UTF-8 - LANG=en_US.UTF-8 + #LC_ALL=en_US.UTF-8 + #LANG=en_US.UTF-8 PYTHONDONTWRITEBYTECODE=1 common: TESTPATH=tests aiohttp: TESTPATH=tests/integrations/aiohttp From a8c6a3a02efd2efbe689c7c300b40555fa26eadd Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 12:38:56 +0200 Subject: [PATCH 06/38] more locale fun --- .github/workflows/test-common.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-common.yml b/.github/workflows/test-common.yml index eed9890bb6..776f25db0c 100644 --- a/.github/workflows/test-common.yml +++ b/.github/workflows/test-common.yml @@ -59,6 +59,8 @@ jobs: set -x # print commands that are executed coverage erase + locale + export LC_ALL=en_US.UTF-8 locale # Run tests From c925befe18f799bb3be9899ef553103a84e08bf0 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 12:42:47 +0200 Subject: [PATCH 07/38] more locales --- .github/workflows/test-common.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-common.yml b/.github/workflows/test-common.yml index 776f25db0c..8d32443723 100644 --- a/.github/workflows/test-common.yml +++ b/.github/workflows/test-common.yml @@ -61,6 +61,8 @@ jobs: locale export LC_ALL=en_US.UTF-8 + export LANG=en_US.UTF-8 + export LANGUAGE=en_US.UTF-8 locale # Run tests From 6f2bfd86ace9dcd417b07d36b70d193b8631519a Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 12:46:48 +0200 Subject: [PATCH 08/38] in tox.ini maybe? --- tox.ini | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index f336e775f0..9c431af772 100644 --- a/tox.ini +++ b/tox.ini @@ -440,8 +440,9 @@ deps = trytond-v{4.6,4.8,5.0,5.2,5.4}: werkzeug<2.0 setenv = - #LC_ALL=en_US.UTF-8 - #LANG=en_US.UTF-8 + LC_ALL=en_US.UTF-8 + LANG=en_US.UTF-8 + LANGUAGE=en_US.UTF-8 PYTHONDONTWRITEBYTECODE=1 common: TESTPATH=tests aiohttp: TESTPATH=tests/integrations/aiohttp From 97d8d9fb49277e0643a6e473828a115ca1685921 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 14:50:18 +0200 Subject: [PATCH 09/38] maybe in passenv? --- tox.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index 9c431af772..2a2bc01762 100644 --- a/tox.ini +++ b/tox.ini @@ -440,9 +440,6 @@ deps = trytond-v{4.6,4.8,5.0,5.2,5.4}: werkzeug<2.0 setenv = - LC_ALL=en_US.UTF-8 - LANG=en_US.UTF-8 - LANGUAGE=en_US.UTF-8 PYTHONDONTWRITEBYTECODE=1 common: TESTPATH=tests aiohttp: TESTPATH=tests/integrations/aiohttp @@ -485,6 +482,9 @@ setenv = COVERAGE_FILE=.coverage-{envname} passenv = + LC_ALL + LANG + LANGUAGE SENTRY_PYTHON_TEST_AWS_ACCESS_KEY_ID SENTRY_PYTHON_TEST_AWS_SECRET_ACCESS_KEY SENTRY_PYTHON_TEST_AWS_IAM_ROLE From 4817a0c36dedf8d708576e3fe3ad6a5a12cf8c83 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 14:57:16 +0200 Subject: [PATCH 10/38] another attempt --- tox.ini | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index 2a2bc01762..a9a373a633 100644 --- a/tox.ini +++ b/tox.ini @@ -440,6 +440,7 @@ deps = trytond-v{4.6,4.8,5.0,5.2,5.4}: werkzeug<2.0 setenv = + PYTHONIOENCODING=utf-8 PYTHONDONTWRITEBYTECODE=1 common: TESTPATH=tests aiohttp: TESTPATH=tests/integrations/aiohttp @@ -482,9 +483,6 @@ setenv = COVERAGE_FILE=.coverage-{envname} passenv = - LC_ALL - LANG - LANGUAGE SENTRY_PYTHON_TEST_AWS_ACCESS_KEY_ID SENTRY_PYTHON_TEST_AWS_SECRET_ACCESS_KEY SENTRY_PYTHON_TEST_AWS_IAM_ROLE From 274ce06c24ebd272f0bd4df68253b236b2b09afa Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 15:09:16 +0200 Subject: [PATCH 11/38] attempt --- tests/conftest.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index af1a40c37e..6b63c5a92b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,6 +2,7 @@ import os import socket from threading import Thread +import sys import pytest import jsonschema @@ -37,6 +38,8 @@ from tests import _warning_recorder, _warning_recorder_mgr +sys.stdin.reconfigure(encoding="utf-8") +sys.stdout.reconfigure(encoding="utf-8") SENTRY_EVENT_SCHEMA = "./checkouts/data-schemas/relay/event.schema.json" From 6b1c0ed79c7f585af77d5e45e7af2e43217db02d Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 15:14:48 +0200 Subject: [PATCH 12/38] test output --- .github/workflows/test-common.yml | 8 ++++++-- tests/conftest.py | 3 --- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-common.yml b/.github/workflows/test-common.yml index 8d32443723..959de69a2e 100644 --- a/.github/workflows/test-common.yml +++ b/.github/workflows/test-common.yml @@ -60,11 +60,15 @@ jobs: coverage erase locale - export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 - export LANGUAGE=en_US.UTF-8 locale + python -c 'import sys; print(sys.getdefaultencoding())' + python -c 'import sys; print(sys.stdin.encoding, sys.stdout.encoding)' + PYTHONIOENCODING="utf-8" python -c 'import sys; print(sys.stdin.encoding, sys.stdout.encoding)' + python -c 'import sys; print(sys.getdefaultencoding())' + python -c 'import sys; print(sys.stdin.encoding, sys.stdout.encoding)' + # Run tests ./scripts/runtox.sh "py${{ matrix.python-version }}-common" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch && coverage combine .coverage* && diff --git a/tests/conftest.py b/tests/conftest.py index 6b63c5a92b..af1a40c37e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,7 +2,6 @@ import os import socket from threading import Thread -import sys import pytest import jsonschema @@ -38,8 +37,6 @@ from tests import _warning_recorder, _warning_recorder_mgr -sys.stdin.reconfigure(encoding="utf-8") -sys.stdout.reconfigure(encoding="utf-8") SENTRY_EVENT_SCHEMA = "./checkouts/data-schemas/relay/event.schema.json" From 7be749e125b830c8436683b2906bac8e8babad31 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 15:19:16 +0200 Subject: [PATCH 13/38] ? --- .github/workflows/test-common.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-common.yml b/.github/workflows/test-common.yml index 959de69a2e..3530d65d17 100644 --- a/.github/workflows/test-common.yml +++ b/.github/workflows/test-common.yml @@ -65,12 +65,12 @@ jobs: python -c 'import sys; print(sys.getdefaultencoding())' python -c 'import sys; print(sys.stdin.encoding, sys.stdout.encoding)' - PYTHONIOENCODING="utf-8" python -c 'import sys; print(sys.stdin.encoding, sys.stdout.encoding)' - python -c 'import sys; print(sys.getdefaultencoding())' + export PYTHONIOENCODING="utf-8" python -c 'import sys; print(sys.stdin.encoding, sys.stdout.encoding)' + python -c 'import sys; print(sys.getdefaultencoding())' # Run tests - ./scripts/runtox.sh "py${{ matrix.python-version }}-common" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch && + PYTHONIOENCODING="utf-8" ./scripts/runtox.sh "py${{ matrix.python-version }}-common" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch && coverage combine .coverage* && coverage xml -i From 06a4cbc2be16e65b6872f0d8b6efed61d28d0f8a Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 15:26:19 +0200 Subject: [PATCH 14/38] ? --- scripts/runtox.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/runtox.sh b/scripts/runtox.sh index 07db62242b..882436bddf 100755 --- a/scripts/runtox.sh +++ b/scripts/runtox.sh @@ -16,4 +16,7 @@ fi searchstring="$1" export TOX_PARALLEL_NO_SPINNER=1 +export PYTHONIOENCODING="utf-8" +export LANG=en_US.UTF-8 +export LC_ALL=en_US.UTF-8 exec $TOXPATH -vv -p auto -e "$($TOXPATH -l | grep "$searchstring" | tr $'\n' ',')" -- "${@:2}" From 1be53ccc647a29102bbbbd6a5d93559c692c5227 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 15:33:34 +0200 Subject: [PATCH 15/38] another attempt --- scripts/runtox.sh | 2 +- tests/test_basics.py | 1 - tox.ini | 2 ++ 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/runtox.sh b/scripts/runtox.sh index 882436bddf..03914de001 100755 --- a/scripts/runtox.sh +++ b/scripts/runtox.sh @@ -19,4 +19,4 @@ export TOX_PARALLEL_NO_SPINNER=1 export PYTHONIOENCODING="utf-8" export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8 -exec $TOXPATH -vv -p auto -e "$($TOXPATH -l | grep "$searchstring" | tr $'\n' ',')" -- "${@:2}" +PYTHONIOENCODING="utf-8" LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 exec $TOXPATH -vv -p auto -e "$($TOXPATH -l | grep "$searchstring" | tr $'\n' ',')" -- "${@:2}" diff --git a/tests/test_basics.py b/tests/test_basics.py index d28511ac74..3913402cbd 100644 --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -73,7 +73,6 @@ def test_auto_enabling_integrations_catches_import_error(sentry_init, caplog): def test_event_id(sentry_init, capture_events): sentry_init() events = capture_events() - assert False # XXX for testing the ci try: diff --git a/tox.ini b/tox.ini index a9a373a633..491ed4bc4c 100644 --- a/tox.ini +++ b/tox.ini @@ -440,6 +440,8 @@ deps = trytond-v{4.6,4.8,5.0,5.2,5.4}: werkzeug<2.0 setenv = + LANG=en_US.UTF-8 + LC_ALL=en_US.UTF-8 PYTHONIOENCODING=utf-8 PYTHONDONTWRITEBYTECODE=1 common: TESTPATH=tests From 402b848549e3d207b845fa9ae0c4048d0e7ab90c Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 15:33:41 +0200 Subject: [PATCH 16/38] Remove extra space --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 491ed4bc4c..e435fc1c3d 100644 --- a/tox.ini +++ b/tox.ini @@ -475,8 +475,8 @@ setenv = requests: TESTPATH=tests/integrations/requests rq: TESTPATH=tests/integrations/rq sanic: TESTPATH=tests/integrations/sanic - starlette: TESTPATH=tests/integrations/starlette - starlite: TESTPATH=tests/integrations/starlite + starlette: TESTPATH=tests/integrations/starlette + starlite: TESTPATH=tests/integrations/starlite sqlalchemy: TESTPATH=tests/integrations/sqlalchemy tornado: TESTPATH=tests/integrations/tornado trytond: TESTPATH=tests/integrations/trytond From 63eee7abc0f36e5c32d175528859963224b59299 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 15:59:05 +0200 Subject: [PATCH 17/38] . --- scripts/runtox.sh | 5 +---- tox.ini | 7 ++++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/runtox.sh b/scripts/runtox.sh index 03914de001..1d1dd2715f 100755 --- a/scripts/runtox.sh +++ b/scripts/runtox.sh @@ -16,7 +16,4 @@ fi searchstring="$1" export TOX_PARALLEL_NO_SPINNER=1 -export PYTHONIOENCODING="utf-8" -export LANG=en_US.UTF-8 -export LC_ALL=en_US.UTF-8 -PYTHONIOENCODING="utf-8" LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 exec $TOXPATH -vv -p auto -e "$($TOXPATH -l | grep "$searchstring" | tr $'\n' ',')" -- "${@:2}" +LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 exec $TOXPATH -vv -p auto -e "$($TOXPATH -l | grep "$searchstring" | tr $'\n' ',')" -- "${@:2}" diff --git a/tox.ini b/tox.ini index e435fc1c3d..dcff430bf6 100644 --- a/tox.ini +++ b/tox.ini @@ -440,9 +440,10 @@ deps = trytond-v{4.6,4.8,5.0,5.2,5.4}: werkzeug<2.0 setenv = - LANG=en_US.UTF-8 - LC_ALL=en_US.UTF-8 - PYTHONIOENCODING=utf-8 + LANG="en_US.UTF-8" + LC_ALL="en_US.UTF-8" + LC_CTYPE="en_US.UTF-8" + PYTHONIOENCODING="utf-8" PYTHONDONTWRITEBYTECODE=1 common: TESTPATH=tests aiohttp: TESTPATH=tests/integrations/aiohttp From 2708e0bcb838f08b0858b06b886d02e1e1929f80 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 16:03:55 +0200 Subject: [PATCH 18/38] quotes? --- tox.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index dcff430bf6..535e1bbcd4 100644 --- a/tox.ini +++ b/tox.ini @@ -440,10 +440,10 @@ deps = trytond-v{4.6,4.8,5.0,5.2,5.4}: werkzeug<2.0 setenv = - LANG="en_US.UTF-8" - LC_ALL="en_US.UTF-8" - LC_CTYPE="en_US.UTF-8" - PYTHONIOENCODING="utf-8" + LANG=en_US.UTF-8 + LC_ALL=en_US.UTF-8 + LC_CTYPE=en_US.UTF-8 + PYTHONIOENCODING=utf-8 PYTHONDONTWRITEBYTECODE=1 common: TESTPATH=tests aiohttp: TESTPATH=tests/integrations/aiohttp From 3b62ae698c06f3cd01d34151e86d850366117f4a Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 17:05:01 +0200 Subject: [PATCH 19/38] ?? --- .github/workflows/test-common.yml | 2 -- tox.ini | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-common.yml b/.github/workflows/test-common.yml index 3530d65d17..d408bb5170 100644 --- a/.github/workflows/test-common.yml +++ b/.github/workflows/test-common.yml @@ -63,11 +63,9 @@ jobs: export LANG=en_US.UTF-8 locale - python -c 'import sys; print(sys.getdefaultencoding())' python -c 'import sys; print(sys.stdin.encoding, sys.stdout.encoding)' export PYTHONIOENCODING="utf-8" python -c 'import sys; print(sys.stdin.encoding, sys.stdout.encoding)' - python -c 'import sys; print(sys.getdefaultencoding())' # Run tests PYTHONIOENCODING="utf-8" ./scripts/runtox.sh "py${{ matrix.python-version }}-common" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch && diff --git a/tox.ini b/tox.ini index 535e1bbcd4..50a2b3cdf2 100644 --- a/tox.ini +++ b/tox.ini @@ -535,6 +535,8 @@ commands = ; when loading tests in scenarios. In particular, django fails to ; load the settings from the test module. + env + {py2.7}: python -m pytest --ignore-glob='*py3.py' -rsx -s --durations=5 -vvv {env:TESTPATH} {posargs} {py3.5,py3.6,py3.7,py3.8,py3.9,py3.10,py3.11}: python -m pytest -rsx -s --durations=5 -vvv {env:TESTPATH} {posargs} From 49e6a998686073e882dc3a2f8789b599548027ea Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 18:49:55 +0200 Subject: [PATCH 20/38] . --- .github/workflows/test-common.yml | 1 + tox.ini | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-common.yml b/.github/workflows/test-common.yml index d408bb5170..ff125309cf 100644 --- a/.github/workflows/test-common.yml +++ b/.github/workflows/test-common.yml @@ -61,6 +61,7 @@ jobs: locale export LANG=en_US.UTF-8 + export LC_ALL=en_US.UTF-8 locale python -c 'import sys; print(sys.stdin.encoding, sys.stdout.encoding)' diff --git a/tox.ini b/tox.ini index 50a2b3cdf2..eaf297d7fc 100644 --- a/tox.ini +++ b/tox.ini @@ -442,7 +442,6 @@ deps = setenv = LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 - LC_CTYPE=en_US.UTF-8 PYTHONIOENCODING=utf-8 PYTHONDONTWRITEBYTECODE=1 common: TESTPATH=tests @@ -486,6 +485,9 @@ setenv = COVERAGE_FILE=.coverage-{envname} passenv = + LANG + LC_ALL + PYTHONIOENCODING SENTRY_PYTHON_TEST_AWS_ACCESS_KEY_ID SENTRY_PYTHON_TEST_AWS_SECRET_ACCESS_KEY SENTRY_PYTHON_TEST_AWS_IAM_ROLE @@ -534,9 +536,6 @@ commands = ; Running `py.test` as an executable suffers from an import error ; when loading tests in scenarios. In particular, django fails to ; load the settings from the test module. - - env - {py2.7}: python -m pytest --ignore-glob='*py3.py' -rsx -s --durations=5 -vvv {env:TESTPATH} {posargs} {py3.5,py3.6,py3.7,py3.8,py3.9,py3.10,py3.11}: python -m pytest -rsx -s --durations=5 -vvv {env:TESTPATH} {posargs} From b0dba47ff4ac64a987100a612fee443393f21cbd Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 18:50:07 +0200 Subject: [PATCH 21/38] . --- tox.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tox.ini b/tox.ini index eaf297d7fc..0c908a60b9 100644 --- a/tox.ini +++ b/tox.ini @@ -536,6 +536,8 @@ commands = ; Running `py.test` as an executable suffers from an import error ; when loading tests in scenarios. In particular, django fails to ; load the settings from the test module. + env + {py2.7}: python -m pytest --ignore-glob='*py3.py' -rsx -s --durations=5 -vvv {env:TESTPATH} {posargs} {py3.5,py3.6,py3.7,py3.8,py3.9,py3.10,py3.11}: python -m pytest -rsx -s --durations=5 -vvv {env:TESTPATH} {posargs} From 759f9845c45f698b46de06749bed2db99a674563 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 19:07:45 +0200 Subject: [PATCH 22/38] . --- .github/workflows/test-common.yml | 2 +- scripts/runtox.sh | 2 +- tests/conftest.py | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-common.yml b/.github/workflows/test-common.yml index ff125309cf..73701f489d 100644 --- a/.github/workflows/test-common.yml +++ b/.github/workflows/test-common.yml @@ -69,7 +69,7 @@ jobs: python -c 'import sys; print(sys.stdin.encoding, sys.stdout.encoding)' # Run tests - PYTHONIOENCODING="utf-8" ./scripts/runtox.sh "py${{ matrix.python-version }}-common" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch && + ../scripts/runtox.sh "py${{ matrix.python-version }}-common" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch && coverage combine .coverage* && coverage xml -i diff --git a/scripts/runtox.sh b/scripts/runtox.sh index 1d1dd2715f..07db62242b 100755 --- a/scripts/runtox.sh +++ b/scripts/runtox.sh @@ -16,4 +16,4 @@ fi searchstring="$1" export TOX_PARALLEL_NO_SPINNER=1 -LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 exec $TOXPATH -vv -p auto -e "$($TOXPATH -l | grep "$searchstring" | tr $'\n' ',')" -- "${@:2}" +exec $TOXPATH -vv -p auto -e "$($TOXPATH -l | grep "$searchstring" | tr $'\n' ',')" -- "${@:2}" diff --git a/tests/conftest.py b/tests/conftest.py index af1a40c37e..e8d5746210 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -37,6 +37,9 @@ from tests import _warning_recorder, _warning_recorder_mgr +import sys + +sys.setdefaultencoding("utf-8") SENTRY_EVENT_SCHEMA = "./checkouts/data-schemas/relay/event.schema.json" From f4da3cd6bd04989630a7b0e4127af4b421387919 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 19:09:43 +0200 Subject: [PATCH 23/38] . --- .github/workflows/test-common.yml | 2 +- tox.ini | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test-common.yml b/.github/workflows/test-common.yml index 73701f489d..6f0d5873da 100644 --- a/.github/workflows/test-common.yml +++ b/.github/workflows/test-common.yml @@ -69,7 +69,7 @@ jobs: python -c 'import sys; print(sys.stdin.encoding, sys.stdout.encoding)' # Run tests - ../scripts/runtox.sh "py${{ matrix.python-version }}-common" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch && + ./scripts/runtox.sh "py${{ matrix.python-version }}-common" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch && coverage combine .coverage* && coverage xml -i diff --git a/tox.ini b/tox.ini index 0c908a60b9..eaf297d7fc 100644 --- a/tox.ini +++ b/tox.ini @@ -536,8 +536,6 @@ commands = ; Running `py.test` as an executable suffers from an import error ; when loading tests in scenarios. In particular, django fails to ; load the settings from the test module. - env - {py2.7}: python -m pytest --ignore-glob='*py3.py' -rsx -s --durations=5 -vvv {env:TESTPATH} {posargs} {py3.5,py3.6,py3.7,py3.8,py3.9,py3.10,py3.11}: python -m pytest -rsx -s --durations=5 -vvv {env:TESTPATH} {posargs} From b4f6eb8bf00babd779a33ebea09a191cc2fface7 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 19:14:48 +0200 Subject: [PATCH 24/38] . --- tests/conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/conftest.py b/tests/conftest.py index e8d5746210..715015f6e5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -39,6 +39,7 @@ import sys +reload(sys) # noqa sys.setdefaultencoding("utf-8") SENTRY_EVENT_SCHEMA = "./checkouts/data-schemas/relay/event.schema.json" From 534462f57ee83a9ad0ed9d3a03d3ce797ca922bb Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 19:41:10 +0200 Subject: [PATCH 25/38] . --- scripts/runtox.sh | 8 +++++++- tests/conftest.py | 4 ---- tox.ini | 7 ------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/scripts/runtox.sh b/scripts/runtox.sh index 07db62242b..32b6fd42ec 100755 --- a/scripts/runtox.sh +++ b/scripts/runtox.sh @@ -16,4 +16,10 @@ fi searchstring="$1" export TOX_PARALLEL_NO_SPINNER=1 -exec $TOXPATH -vv -p auto -e "$($TOXPATH -l | grep "$searchstring" | tr $'\n' ',')" -- "${@:2}" +ENV="$($TOXPATH -l | grep "$searchstring" | tr $'\n' ',')" + +if [ "$ENV" = py2.7-common, ]; then + exec $TOXPATH -vv -e "${ENV}" -- "${@:2}" +else + exec $TOXPATH -vv -p auto -e "${ENV}" -- "${@:2}" +fi diff --git a/tests/conftest.py b/tests/conftest.py index 715015f6e5..af1a40c37e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -37,10 +37,6 @@ from tests import _warning_recorder, _warning_recorder_mgr -import sys - -reload(sys) # noqa -sys.setdefaultencoding("utf-8") SENTRY_EVENT_SCHEMA = "./checkouts/data-schemas/relay/event.schema.json" diff --git a/tox.ini b/tox.ini index eaf297d7fc..5698398e6e 100644 --- a/tox.ini +++ b/tox.ini @@ -440,10 +440,6 @@ deps = trytond-v{4.6,4.8,5.0,5.2,5.4}: werkzeug<2.0 setenv = - LANG=en_US.UTF-8 - LC_ALL=en_US.UTF-8 - PYTHONIOENCODING=utf-8 - PYTHONDONTWRITEBYTECODE=1 common: TESTPATH=tests aiohttp: TESTPATH=tests/integrations/aiohttp arq: TESTPATH=tests/integrations/arq @@ -485,9 +481,6 @@ setenv = COVERAGE_FILE=.coverage-{envname} passenv = - LANG - LC_ALL - PYTHONIOENCODING SENTRY_PYTHON_TEST_AWS_ACCESS_KEY_ID SENTRY_PYTHON_TEST_AWS_SECRET_ACCESS_KEY SENTRY_PYTHON_TEST_AWS_IAM_ROLE From 9b9f84e01b94236743d6cf939c7659362d57a498 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 19:46:51 +0200 Subject: [PATCH 26/38] . --- scripts/runtox.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/runtox.sh b/scripts/runtox.sh index 32b6fd42ec..7dbab641cd 100755 --- a/scripts/runtox.sh +++ b/scripts/runtox.sh @@ -18,8 +18,8 @@ searchstring="$1" export TOX_PARALLEL_NO_SPINNER=1 ENV="$($TOXPATH -l | grep "$searchstring" | tr $'\n' ',')" -if [ "$ENV" = py2.7-common, ]; then - exec $TOXPATH -vv -e "${ENV}" -- "${@:2}" +if [ "$ENV" = py2.7-common, ] || [ "$ENV" = py2.7-gevent, ]; then + exec $TOXPATH -vv -e "$ENV" -- "${@:2}" else - exec $TOXPATH -vv -p auto -e "${ENV}" -- "${@:2}" + exec $TOXPATH -vv -p auto -e "$ENV" -- "${@:2}" fi From fab1c8ec4f78c0086be23945187d9e133bed2d62 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Mon, 5 Jun 2023 19:47:11 +0200 Subject: [PATCH 27/38] . --- tests/test_basics.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_basics.py b/tests/test_basics.py index 3913402cbd..751b0a617b 100644 --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -73,7 +73,6 @@ def test_auto_enabling_integrations_catches_import_error(sentry_init, caplog): def test_event_id(sentry_init, capture_events): sentry_init() events = capture_events() - assert False # XXX for testing the ci try: raise ValueError("aha!") From d4b055c63036942379526ca67f91bab49acfab35 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Tue, 6 Jun 2023 11:26:39 +0200 Subject: [PATCH 28/38] remove locale stuff --- .github/workflows/test-common.yml | 9 --------- scripts/runtox.sh | 2 ++ 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test-common.yml b/.github/workflows/test-common.yml index 6f0d5873da..46aec35dd4 100644 --- a/.github/workflows/test-common.yml +++ b/.github/workflows/test-common.yml @@ -59,15 +59,6 @@ jobs: set -x # print commands that are executed coverage erase - locale - export LANG=en_US.UTF-8 - export LC_ALL=en_US.UTF-8 - locale - - python -c 'import sys; print(sys.stdin.encoding, sys.stdout.encoding)' - export PYTHONIOENCODING="utf-8" - python -c 'import sys; print(sys.stdin.encoding, sys.stdout.encoding)' - # Run tests ./scripts/runtox.sh "py${{ matrix.python-version }}-common" --cov=tests --cov=sentry_sdk --cov-report= --cov-branch && coverage combine .coverage* && diff --git a/scripts/runtox.sh b/scripts/runtox.sh index 7dbab641cd..e099f44efe 100755 --- a/scripts/runtox.sh +++ b/scripts/runtox.sh @@ -18,6 +18,8 @@ searchstring="$1" export TOX_PARALLEL_NO_SPINNER=1 ENV="$($TOXPATH -l | grep "$searchstring" | tr $'\n' ',')" +# Run the common 2.7 suite without the -p flag, otherwise we hit an encoding +# issue in tox. if [ "$ENV" = py2.7-common, ] || [ "$ENV" = py2.7-gevent, ]; then exec $TOXPATH -vv -e "$ENV" -- "${@:2}" else From 6036689275aa60fc6ba2b0a36c1348b7b4713908 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Tue, 6 Jun 2023 11:28:30 +0200 Subject: [PATCH 29/38] . --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 5698398e6e..040d6659df 100644 --- a/tox.ini +++ b/tox.ini @@ -440,6 +440,7 @@ deps = trytond-v{4.6,4.8,5.0,5.2,5.4}: werkzeug<2.0 setenv = + PYTHONDONTWRITEBYTECODE=1 common: TESTPATH=tests aiohttp: TESTPATH=tests/integrations/aiohttp arq: TESTPATH=tests/integrations/arq From 58b7e74f1907a1816e1b8704e119249b5d946d38 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Tue, 6 Jun 2023 13:17:15 +0200 Subject: [PATCH 30/38] test fixes --- sentry_sdk/integrations/socket.py | 2 ++ .../integrations/threading/test_threading.py | 24 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/sentry_sdk/integrations/socket.py b/sentry_sdk/integrations/socket.py index d3af70794b..7a4e358185 100644 --- a/sentry_sdk/integrations/socket.py +++ b/sentry_sdk/integrations/socket.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + import socket from sentry_sdk import Hub from sentry_sdk._types import MYPY diff --git a/tests/integrations/threading/test_threading.py b/tests/integrations/threading/test_threading.py index 56f7a36ea3..c1d4c3166f 100644 --- a/tests/integrations/threading/test_threading.py +++ b/tests/integrations/threading/test_threading.py @@ -1,5 +1,5 @@ import gc - +import sys from threading import Thread import pytest @@ -121,6 +121,7 @@ def run(self): assert exception["type"] == "ZeroDivisionError" +@pytest.mark.skipif(sys.version_info == (2, 7), reason="no __qualname__ in py2.7") def test_wrapper_attributes(sentry_init): sentry_init(default_integrations=False, integrations=[ThreadingIntegration()]) @@ -141,3 +142,24 @@ def target(): assert Thread.run.__qualname__ == original_run.__qualname__ assert t.run.__name__ == "run" assert t.run.__qualname__ == original_run.__qualname__ + + +@pytest.mark.skipif( + sys.version_info > (2, 7), + reason="simpler test for py2.7 without py3 only __qualname__", +) +def test_wrapper_attributes_no_qualname(sentry_init): + sentry_init(default_integrations=False, integrations=[ThreadingIntegration()]) + + def target(): + assert t.run.__name__ == "run" + + t = Thread(target=target) + t.start() + t.join() + + assert Thread.start.__name__ == "start" + assert t.start.__name__ == "start" + + assert Thread.run.__name__ == "run" + assert t.run.__name__ == "run" From 6f2f508ca5c61b0df94c78e2368c8d963b6ac38d Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Tue, 6 Jun 2023 13:21:35 +0200 Subject: [PATCH 31/38] . From 1a94f79298e1a2b3839a09a791121771d76c6cb3 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Tue, 6 Jun 2023 13:29:25 +0200 Subject: [PATCH 32/38] skip if old --- tests/integrations/threading/test_threading.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integrations/threading/test_threading.py b/tests/integrations/threading/test_threading.py index c1d4c3166f..912717dddd 100644 --- a/tests/integrations/threading/test_threading.py +++ b/tests/integrations/threading/test_threading.py @@ -121,7 +121,7 @@ def run(self): assert exception["type"] == "ZeroDivisionError" -@pytest.mark.skipif(sys.version_info == (2, 7), reason="no __qualname__ in py2.7") +@pytest.mark.skipif(sys.version_info < (3, 2), reason="no __qualname__ in older python") def test_wrapper_attributes(sentry_init): sentry_init(default_integrations=False, integrations=[ThreadingIntegration()]) From 002d9f6c359e655b6ceca868f5a07020c54eef18 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Tue, 6 Jun 2023 14:05:15 +0200 Subject: [PATCH 33/38] mark all exceptiongroup tests with >=3.11 --- tests/test_exceptiongroup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_exceptiongroup.py b/tests/test_exceptiongroup.py index 47b3344dc6..8d4734762a 100644 --- a/tests/test_exceptiongroup.py +++ b/tests/test_exceptiongroup.py @@ -194,6 +194,7 @@ def test_exceptiongroup_simple(): assert frame["context_line"] == " raise ExceptionGroup(" +@minimum_python_311 def test_exception_chain_cause(): exception_chain_cause = ValueError("Exception with cause") exception_chain_cause.__context__ = TypeError("Exception in __context__") @@ -235,6 +236,7 @@ def test_exception_chain_cause(): assert exception_values == expected_exception_values +@minimum_python_311 def test_exception_chain_context(): exception_chain_context = ValueError("Exception with context") exception_chain_context.__context__ = TypeError("Exception in __context__") @@ -273,6 +275,7 @@ def test_exception_chain_context(): assert exception_values == expected_exception_values +@minimum_python_311 def test_simple_exception(): simple_excpetion = ValueError("A simple exception") From 214526855d70a48ae3d83f52aa84f2c5e95c88af Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Tue, 6 Jun 2023 14:35:04 +0200 Subject: [PATCH 34/38] Disable profiler tests for py2.7 --- tests/test_profiler.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_profiler.py b/tests/test_profiler.py index 11ece9821e..56d9514a85 100644 --- a/tests/test_profiler.py +++ b/tests/test_profiler.py @@ -81,6 +81,7 @@ def test_profiler_invalid_mode(mode, make_options, teardown_profiling): setup_profiler(make_options(mode)) +@requires_python_version(3, 3) @pytest.mark.parametrize( "mode", [ @@ -116,6 +117,7 @@ def test_profiler_setup_twice(make_options, teardown_profiling): assert not setup_profiler(make_options()) +@requires_python_version(3, 3) @pytest.mark.parametrize( "mode", [ @@ -173,6 +175,7 @@ def test_profiles_sample_rate( assert len(items["profile"]) == profile_count +@requires_python_version(3, 3) @pytest.mark.parametrize( "mode", [ @@ -234,6 +237,7 @@ def test_profiles_sampler( assert len(items["profile"]) == profile_count +@requires_python_version(3, 3) def test_minimum_unique_samples_required( sentry_init, capture_envelopes, @@ -260,6 +264,7 @@ def test_minimum_unique_samples_required( assert len(items["profile"]) == 0 +@requires_python_version(3, 3) def test_profile_captured( sentry_init, capture_envelopes, @@ -349,6 +354,7 @@ def static_method(): return inspect.currentframe() +@requires_python_version(3, 3) @pytest.mark.parametrize( ("frame", "frame_name"), [ @@ -428,6 +434,7 @@ def test_get_frame_name(frame, frame_name): assert get_frame_name(frame) == frame_name +@requires_python_version(3, 3) @pytest.mark.parametrize( ("get_frame", "function"), [ @@ -455,6 +462,7 @@ def test_extract_frame(get_frame, function): assert isinstance(extracted_frame["lineno"], int) +@requires_python_version(3, 3) @pytest.mark.parametrize( ("depth", "max_stack_depth", "actual_depth"), [ @@ -493,6 +501,7 @@ def test_extract_stack_with_max_depth(depth, max_stack_depth, actual_depth): assert frames[actual_depth]["function"] == "", actual_depth +@requires_python_version(3, 3) @pytest.mark.parametrize( ("frame", "depth"), [(get_frame(depth=1), len(inspect.stack()))], @@ -514,6 +523,7 @@ def test_extract_stack_with_cache(frame, depth): assert frame1 is frame2, i +@requires_python_version(3, 3) def test_get_current_thread_id_explicit_thread(): results = Queue(maxsize=1) @@ -535,6 +545,7 @@ def target2(): assert thread1.ident == results.get(timeout=1) +@requires_python_version(3, 3) @requires_gevent def test_get_current_thread_id_gevent_in_thread(): results = Queue(maxsize=1) @@ -550,6 +561,7 @@ def target(): assert thread.ident == results.get(timeout=1) +@requires_python_version(3, 3) def test_get_current_thread_id_running_thread(): results = Queue(maxsize=1) @@ -562,6 +574,7 @@ def target(): assert thread.ident == results.get(timeout=1) +@requires_python_version(3, 3) def test_get_current_thread_id_main_thread(): results = Queue(maxsize=1) @@ -626,6 +639,7 @@ def test_thread_scheduler_single_background_thread(scheduler_class): assert len(get_scheduler_threads(scheduler)) == 0 +@requires_python_version(3, 3) @pytest.mark.parametrize( ("scheduler_class",), [ @@ -684,6 +698,7 @@ def ensure_running(self): ] +@requires_python_version(3, 3) @pytest.mark.parametrize( ("samples", "expected"), [ From ba7288d9b4ec5143da72acfa71786aebde415aec Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Tue, 6 Jun 2023 15:55:15 +0200 Subject: [PATCH 35/38] unicode stuff --- tests/test_serializer.py | 1 + tests/utils/test_general.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_serializer.py b/tests/test_serializer.py index 5bb0579d5a..824fdc2ebf 100644 --- a/tests/test_serializer.py +++ b/tests/test_serializer.py @@ -73,6 +73,7 @@ def test_bytes_serialization_repr(message_normalizer): assert result == r"b'abc123\x80\xf0\x9f\x8d\x95'" +@pytest.mark.xfail(sys.version_info < (3,), reason="Known safe_repr bugs in Py2.7") def test_bytearray_serialization_decode(message_normalizer): binary = bytearray(b"abc123\x80\xf0\x9f\x8d\x95") result = message_normalizer(binary, should_repr_strings=False) diff --git a/tests/utils/test_general.py b/tests/utils/test_general.py index 570182ab0e..8906fdc381 100644 --- a/tests/utils/test_general.py +++ b/tests/utils/test_general.py @@ -587,5 +587,7 @@ def test_strip_string(): assert stripped_text.value.count("a") == 1021 # + '...' is 1024 # If text has unicode characters, it counts bytes and not number of characters. - text_with_unicode_character = "éê" + # fmt: off + text_with_unicode_character = u"éêéê" + # fmt: on assert strip_string(text_with_unicode_character, max_length=2).value == "é..." From 0fe22ec111cfb5d5feb85cfce60dc52cc5ab04b3 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Tue, 6 Jun 2023 16:44:18 +0200 Subject: [PATCH 36/38] more tests --- tests/test_scrubber.py | 12 +++++------- tests/utils/test_general.py | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/test_scrubber.py b/tests/test_scrubber.py index 5bb89ed654..4b2dfff450 100644 --- a/tests/test_scrubber.py +++ b/tests/test_scrubber.py @@ -105,11 +105,9 @@ def test_breadcrumb_extra_scrubbing(sentry_init, capture_events): "password": "[Filtered]", } - assert event["_meta"] == { - "extra": {"auth": {"": {"rem": [["!config", "s"]]}}}, - "breadcrumbs": { - "values": {"0": {"data": {"password": {"": {"rem": [["!config", "s"]]}}}}} - }, + assert event["_meta"]["extra"]["auth"] == {"": {"rem": [["!config", "s"]]}} + assert event["_meta"]["breadcrumbs"] == { + "values": {"0": {"data": {"password": {"": {"rem": [["!config", "s"]]}}}}} } @@ -124,8 +122,8 @@ def test_span_data_scrubbing(sentry_init, capture_events): (event,) = events assert event["spans"][0]["data"] == {"password": "[Filtered]", "datafoo": "databar"} - assert event["_meta"] == { - "spans": {"0": {"data": {"password": {"": {"rem": [["!config", "s"]]}}}}} + assert event["_meta"]["spans"] == { + "0": {"data": {"password": {"": {"rem": [["!config", "s"]]}}}} } diff --git a/tests/utils/test_general.py b/tests/utils/test_general.py index 8906fdc381..de44b1f3bb 100644 --- a/tests/utils/test_general.py +++ b/tests/utils/test_general.py @@ -588,6 +588,6 @@ def test_strip_string(): # If text has unicode characters, it counts bytes and not number of characters. # fmt: off - text_with_unicode_character = u"éêéê" + text_with_unicode_character = u"éê" # fmt: on assert strip_string(text_with_unicode_character, max_length=2).value == "é..." From 044ef9f1010a8c8a54a31d6f9cfd99d33a00bae9 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Tue, 6 Jun 2023 17:22:10 +0200 Subject: [PATCH 37/38] unicode... --- tests/utils/test_general.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/utils/test_general.py b/tests/utils/test_general.py index de44b1f3bb..6f53de32c3 100644 --- a/tests/utils/test_general.py +++ b/tests/utils/test_general.py @@ -589,5 +589,5 @@ def test_strip_string(): # If text has unicode characters, it counts bytes and not number of characters. # fmt: off text_with_unicode_character = u"éê" + assert strip_string(text_with_unicode_character, max_length=2).value == u"é..." # fmt: on - assert strip_string(text_with_unicode_character, max_length=2).value == "é..." From 473b0b00b351e67eeebfbc99b85a6fa968eb7bff Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Tue, 6 Jun 2023 17:32:15 +0200 Subject: [PATCH 38/38] this actually should work --- tests/test_serializer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_serializer.py b/tests/test_serializer.py index 824fdc2ebf..cc62c4663d 100644 --- a/tests/test_serializer.py +++ b/tests/test_serializer.py @@ -73,11 +73,12 @@ def test_bytes_serialization_repr(message_normalizer): assert result == r"b'abc123\x80\xf0\x9f\x8d\x95'" -@pytest.mark.xfail(sys.version_info < (3,), reason="Known safe_repr bugs in Py2.7") def test_bytearray_serialization_decode(message_normalizer): binary = bytearray(b"abc123\x80\xf0\x9f\x8d\x95") result = message_normalizer(binary, should_repr_strings=False) - assert result == "abc123\ufffd\U0001f355" + # fmt: off + assert result == u"abc123\ufffd\U0001f355" + # fmt: on @pytest.mark.xfail(sys.version_info < (3,), reason="Known safe_repr bugs in Py2.7")