|
1 | | -import asyncio |
| 1 | +# import asyncio |
2 | 2 | import concurrent.futures as cf |
3 | 3 |
|
4 | 4 | import sentry_sdk |
|
7 | 7 | add_feature_flag, |
8 | 8 | ) |
9 | 9 |
|
10 | | -import pytest |
11 | | -import sys |
| 10 | +# import pytest |
| 11 | +# import sys |
12 | 12 |
|
13 | 13 |
|
14 | 14 | def test_featureflags_integration(sentry_init, capture_events, uninstall_integration): |
@@ -81,54 +81,56 @@ def task(flag_key): |
81 | 81 | } |
82 | 82 |
|
83 | 83 |
|
84 | | -@pytest.mark.skipif( |
85 | | - sys.version_info < (3, 7), reason="Test requires Python 3.7 or higher" |
86 | | -) |
87 | | -def test_featureflags_integration_asyncio( |
88 | | - sentry_init, capture_events, uninstall_integration |
89 | | -): |
90 | | - uninstall_integration(FeatureFlagsIntegration.identifier) |
91 | | - sentry_init(integrations=[FeatureFlagsIntegration()]) |
92 | | - events = capture_events() |
93 | | - |
94 | | - # Capture an eval before we split isolation scopes. |
95 | | - add_feature_flag("hello", False) |
96 | | - |
97 | | - async def task(flag_key): |
98 | | - # Creates a new isolation scope for the thread. |
99 | | - # This means the evaluations in each task are captured separately. |
100 | | - with sentry_sdk.isolation_scope(): |
101 | | - add_feature_flag(flag_key, False) |
102 | | - # use a tag to identify to identify events later on |
103 | | - sentry_sdk.set_tag("task_id", flag_key) |
104 | | - sentry_sdk.capture_exception(Exception("something wrong!")) |
105 | | - |
106 | | - async def runner(): |
107 | | - return asyncio.gather(task("world"), task("other")) |
108 | | - |
109 | | - asyncio.run(runner()) |
110 | | - |
111 | | - # Capture error in original scope |
112 | | - sentry_sdk.set_tag("task_id", "0") |
113 | | - sentry_sdk.capture_exception(Exception("something wrong!")) |
114 | | - |
115 | | - assert len(events) == 3 |
116 | | - events.sort(key=lambda e: e["tags"]["task_id"]) |
117 | | - |
118 | | - assert events[0]["contexts"]["flags"] == { |
119 | | - "values": [ |
120 | | - {"flag": "hello", "result": False}, |
121 | | - ] |
122 | | - } |
123 | | - assert events[1]["contexts"]["flags"] == { |
124 | | - "values": [ |
125 | | - {"flag": "hello", "result": False}, |
126 | | - {"flag": "other", "result": False}, |
127 | | - ] |
128 | | - } |
129 | | - assert events[2]["contexts"]["flags"] == { |
130 | | - "values": [ |
131 | | - {"flag": "hello", "result": False}, |
132 | | - {"flag": "world", "result": False}, |
133 | | - ] |
134 | | - } |
| 84 | +# |
| 85 | +# |
| 86 | +# @pytest.mark.skipif( |
| 87 | +# sys.version_info < (3, 7), reason="Test requires Python 3.7 or higher" |
| 88 | +# ) |
| 89 | +# def test_featureflags_integration_asyncio( |
| 90 | +# sentry_init, capture_events, uninstall_integration |
| 91 | +# ): |
| 92 | +# uninstall_integration(FeatureFlagsIntegration.identifier) |
| 93 | +# sentry_init(integrations=[FeatureFlagsIntegration()]) |
| 94 | +# events = capture_events() |
| 95 | +# |
| 96 | +# # Capture an eval before we split isolation scopes. |
| 97 | +# add_feature_flag("hello", False) |
| 98 | +# |
| 99 | +# async def task(flag_key): |
| 100 | +# # Creates a new isolation scope for the thread. |
| 101 | +# # This means the evaluations in each task are captured separately. |
| 102 | +# with sentry_sdk.isolation_scope(): |
| 103 | +# add_feature_flag(flag_key, False) |
| 104 | +# # use a tag to identify to identify events later on |
| 105 | +# sentry_sdk.set_tag("task_id", flag_key) |
| 106 | +# sentry_sdk.capture_exception(Exception("something wrong!")) |
| 107 | +# |
| 108 | +# async def runner(): |
| 109 | +# return asyncio.gather(task("world"), task("other")) |
| 110 | +# |
| 111 | +# asyncio.run(runner()) |
| 112 | +# |
| 113 | +# # Capture error in original scope |
| 114 | +# sentry_sdk.set_tag("task_id", "0") |
| 115 | +# sentry_sdk.capture_exception(Exception("something wrong!")) |
| 116 | +# |
| 117 | +# assert len(events) == 3 |
| 118 | +# events.sort(key=lambda e: e["tags"]["task_id"]) |
| 119 | +# |
| 120 | +# assert events[0]["contexts"]["flags"] == { |
| 121 | +# "values": [ |
| 122 | +# {"flag": "hello", "result": False}, |
| 123 | +# ] |
| 124 | +# } |
| 125 | +# assert events[1]["contexts"]["flags"] == { |
| 126 | +# "values": [ |
| 127 | +# {"flag": "hello", "result": False}, |
| 128 | +# {"flag": "other", "result": False}, |
| 129 | +# ] |
| 130 | +# } |
| 131 | +# assert events[2]["contexts"]["flags"] == { |
| 132 | +# "values": [ |
| 133 | +# {"flag": "hello", "result": False}, |
| 134 | +# {"flag": "world", "result": False}, |
| 135 | +# ] |
| 136 | +# } |
0 commit comments