Skip to content

Commit f82342c

Browse files
committed
unstuck
1 parent 9502dd5 commit f82342c

File tree

1 file changed

+23
-34
lines changed

1 file changed

+23
-34
lines changed

tests/integrations/bottle/test_bottle.py

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
from werkzeug.test import Client
1313
from werkzeug.wrappers import Response
1414

15-
import sentry_sdk.integrations.bottle as bottle_sentry
16-
1715

1816
@pytest.fixture(scope="function")
1917
def app(sentry_init):
@@ -46,7 +44,7 @@ def inner():
4644

4745

4846
def test_has_context(sentry_init, app, capture_events, get_client):
49-
sentry_init(integrations=[bottle_sentry.BottleIntegration()])
47+
sentry_init(integrations=[BottleIntegration()])
5048
events = capture_events()
5149

5250
client = get_client()
@@ -77,11 +75,7 @@ def test_transaction_style(
7775
capture_events,
7876
get_client,
7977
):
80-
sentry_init(
81-
integrations=[
82-
bottle_sentry.BottleIntegration(transaction_style=transaction_style)
83-
]
84-
)
78+
sentry_init(integrations=[BottleIntegration(transaction_style=transaction_style)])
8579
events = capture_events()
8680

8781
client = get_client()
@@ -100,7 +94,7 @@ def test_transaction_style(
10094
def test_errors(
10195
sentry_init, capture_exceptions, capture_events, app, debug, catchall, get_client
10296
):
103-
sentry_init(integrations=[bottle_sentry.BottleIntegration()])
97+
sentry_init(integrations=[BottleIntegration()])
10498

10599
app.catchall = catchall
106100
set_debug(mode=debug)
@@ -127,7 +121,7 @@ def index():
127121

128122

129123
def test_large_json_request(sentry_init, capture_events, app, get_client):
130-
sentry_init(integrations=[bottle_sentry.BottleIntegration()])
124+
sentry_init(integrations=[BottleIntegration()])
131125

132126
data = {"foo": {"bar": "a" * 2000}}
133127

@@ -157,7 +151,7 @@ def index():
157151

158152
@pytest.mark.parametrize("data", [{}, []], ids=["empty-dict", "empty-list"])
159153
def test_empty_json_request(sentry_init, capture_events, app, data, get_client):
160-
sentry_init(integrations=[bottle_sentry.BottleIntegration()])
154+
sentry_init(integrations=[BottleIntegration()])
161155

162156
@app.route("/", method="POST")
163157
def index():
@@ -180,7 +174,7 @@ def index():
180174

181175

182176
def test_medium_formdata_request(sentry_init, capture_events, app, get_client):
183-
sentry_init(integrations=[bottle_sentry.BottleIntegration()])
177+
sentry_init(integrations=[BottleIntegration()])
184178

185179
data = {"foo": "a" * 2000}
186180

@@ -209,9 +203,7 @@ def index():
209203
def test_too_large_raw_request(
210204
sentry_init, input_char, capture_events, app, get_client
211205
):
212-
sentry_init(
213-
integrations=[bottle_sentry.BottleIntegration()], max_request_body_size="small"
214-
)
206+
sentry_init(integrations=[BottleIntegration()], max_request_body_size="small")
215207

216208
data = input_char * 2000
217209

@@ -239,9 +231,7 @@ def index():
239231

240232

241233
def test_files_and_form(sentry_init, capture_events, app, get_client):
242-
sentry_init(
243-
integrations=[bottle_sentry.BottleIntegration()], max_request_body_size="always"
244-
)
234+
sentry_init(integrations=[BottleIntegration()], max_request_body_size="always")
245235

246236
data = {"foo": "a" * 2000, "file": (BytesIO(b"hello"), "hello.txt")}
247237

@@ -278,9 +268,7 @@ def index():
278268
def test_json_not_truncated_if_max_request_body_size_is_always(
279269
sentry_init, capture_events, app, get_client
280270
):
281-
sentry_init(
282-
integrations=[bottle_sentry.BottleIntegration()], max_request_body_size="always"
283-
)
271+
sentry_init(integrations=[BottleIntegration()], max_request_body_size="always")
284272

285273
data = {
286274
"key{}".format(i): "value{}".format(i) for i in range(MAX_DATABAG_BREADTH + 10)
@@ -309,8 +297,8 @@ def index():
309297
@pytest.mark.parametrize(
310298
"integrations",
311299
[
312-
[bottle_sentry.BottleIntegration()],
313-
[bottle_sentry.BottleIntegration(), LoggingIntegration(event_level="ERROR")],
300+
[BottleIntegration()],
301+
[BottleIntegration(), LoggingIntegration(event_level="ERROR")],
314302
],
315303
)
316304
def test_errors_not_reported_twice(
@@ -324,23 +312,24 @@ def test_errors_not_reported_twice(
324312

325313
@app.route("/")
326314
def index():
327-
try:
328-
1 / 0
329-
except Exception as e:
330-
logger.exception(e)
331-
raise e
315+
1 / 0
332316

333317
events = capture_events()
334318

335319
client = get_client()
320+
336321
with pytest.raises(ZeroDivisionError):
337-
client.get("/")
322+
try:
323+
client.get("/")
324+
except ZeroDivisionError as e:
325+
logger.exception(e)
326+
raise e
338327

339328
assert len(events) == 1
340329

341330

342331
def test_mount(app, capture_exceptions, capture_events, sentry_init, get_client):
343-
sentry_init(integrations=[bottle_sentry.BottleIntegration()])
332+
sentry_init(integrations=[BottleIntegration()])
344333

345334
app.catchall = False
346335

@@ -367,7 +356,7 @@ def crashing_app(environ, start_response):
367356

368357

369358
def test_error_in_errorhandler(sentry_init, capture_events, app, get_client):
370-
sentry_init(integrations=[bottle_sentry.BottleIntegration()])
359+
sentry_init(integrations=[BottleIntegration()])
371360

372361
set_debug(False)
373362
app.catchall = True
@@ -397,7 +386,7 @@ def error_handler(err):
397386

398387

399388
def test_bad_request_not_captured(sentry_init, capture_events, app, get_client):
400-
sentry_init(integrations=[bottle_sentry.BottleIntegration()])
389+
sentry_init(integrations=[BottleIntegration()])
401390
events = capture_events()
402391

403392
@app.route("/")
@@ -412,7 +401,7 @@ def index():
412401

413402

414403
def test_no_exception_on_redirect(sentry_init, capture_events, app, get_client):
415-
sentry_init(integrations=[bottle_sentry.BottleIntegration()])
404+
sentry_init(integrations=[BottleIntegration()])
416405
events = capture_events()
417406

418407
@app.route("/")
@@ -436,7 +425,7 @@ def test_span_origin(
436425
capture_events,
437426
):
438427
sentry_init(
439-
integrations=[bottle_sentry.BottleIntegration()],
428+
integrations=[BottleIntegration()],
440429
traces_sample_rate=1.0,
441430
)
442431
events = capture_events()

0 commit comments

Comments
 (0)