|
4 | 4 | import socket |
5 | 5 | import sys |
6 | 6 | import asyncio |
7 | | -import threading |
8 | 7 | from collections import defaultdict |
9 | 8 | from datetime import datetime, timedelta, timezone |
10 | 9 | from unittest import mock |
@@ -879,41 +878,6 @@ def test_record_lost_event_transaction_item(capturing_server, make_client, span_ |
879 | 878 | } in discarded_events |
880 | 879 |
|
881 | 880 |
|
882 | | -def test_handle_unexpected_status_invokes_handle_request_error( |
883 | | - make_client, monkeypatch |
884 | | -): |
885 | | - client = make_client() |
886 | | - transport = client.transport |
887 | | - |
888 | | - monkeypatch.setattr(transport._worker, "submit", lambda fn: fn() or True) |
889 | | - |
890 | | - def stub_request(method, endpoint, body=None, headers=None): |
891 | | - class MockResponse: |
892 | | - def __init__(self): |
893 | | - self.status = 500 # Integer |
894 | | - self.data = b"server error" |
895 | | - self.headers = {} |
896 | | - |
897 | | - def close(self): |
898 | | - pass |
899 | | - |
900 | | - return MockResponse() |
901 | | - |
902 | | - monkeypatch.setattr(transport, "_request", stub_request) |
903 | | - |
904 | | - seen = [] |
905 | | - monkeypatch.setattr( |
906 | | - transport, |
907 | | - "_handle_request_error", |
908 | | - lambda envelope, loss_reason: seen.append(loss_reason), |
909 | | - ) |
910 | | - |
911 | | - client.capture_event({"message": "test"}) |
912 | | - client.flush() |
913 | | - |
914 | | - assert seen == ["status_500"] |
915 | | - |
916 | | - |
917 | 881 | @skip_under_gevent |
918 | 882 | @pytest.mark.asyncio |
919 | 883 | @pytest.mark.parametrize("debug", (True, False)) |
@@ -996,42 +960,6 @@ async def test_transport_works_async( |
996 | 960 | await client.close_async(timeout=2.0) |
997 | 961 |
|
998 | 962 |
|
999 | | -@skip_under_gevent |
1000 | | -@pytest.mark.asyncio |
1001 | | -@pytest.mark.skipif(not PY38, reason="Async transport requires Python 3.8+") |
1002 | | -async def test_async_transport_background_thread_capture( |
1003 | | - capturing_server, make_client, caplog |
1004 | | -): |
1005 | | - """Test capture_envelope from background threads uses run_coroutine_threadsafe""" |
1006 | | - caplog.set_level(logging.DEBUG) |
1007 | | - client = make_client( |
1008 | | - _experiments={"transport_async": True}, integrations=[AsyncioIntegration()] |
1009 | | - ) |
1010 | | - assert isinstance(client.transport, AsyncHttpTransport) |
1011 | | - sentry_sdk.get_global_scope().set_client(client) |
1012 | | - try: |
1013 | | - captured_from_thread = [] |
1014 | | - exception_from_thread = [] |
1015 | | - |
1016 | | - def background_thread_work(): |
1017 | | - try: |
1018 | | - # This should use run_coroutine_threadsafe path |
1019 | | - capture_message("from background thread") |
1020 | | - captured_from_thread.append(True) |
1021 | | - except Exception as e: |
1022 | | - exception_from_thread.append(e) |
1023 | | - |
1024 | | - thread = threading.Thread(target=background_thread_work) |
1025 | | - thread.start() |
1026 | | - thread.join() |
1027 | | - assert not exception_from_thread |
1028 | | - assert captured_from_thread |
1029 | | - await client.close_async(timeout=2.0) |
1030 | | - assert capturing_server.captured |
1031 | | - finally: |
1032 | | - sentry_sdk.get_global_scope().set_client(None) |
1033 | | - |
1034 | | - |
1035 | 963 | @skip_under_gevent |
1036 | 964 | @pytest.mark.asyncio |
1037 | 965 | @pytest.mark.skipif(not PY38, reason="Async transport requires Python 3.8+") |
|
0 commit comments