Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low hanging fruit to test the UserWarnings and reduce noise in the pytest output

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great attention to details @wurstnase! Thank you so much!! ❤️

Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,8 @@ def raises_error():
def test_powertools_dev_sets_debug_mode(monkeypatch):
# GIVEN a debug mode environment variable is set
monkeypatch.setenv(constants.POWERTOOLS_DEV_ENV, "true")
app = ApiGatewayResolver()
with pytest.warns(UserWarning, match="POWERTOOLS_DEV environment variable is enabled."):
app = ApiGatewayResolver()

# WHEN calling app._debug
# THEN the debug mode is enabled
Expand Down Expand Up @@ -1428,7 +1429,8 @@ def get_func():
def get_func_another_duplicate():
raise RuntimeError()

app.include_router(router)
with pytest.warns(UserWarning, match="A route like this was already registered"):
app.include_router(router)

# WHEN calling the handler
result = app(LOAD_GW_EVENT, None)
Expand Down Expand Up @@ -1707,7 +1709,12 @@ def my_path():
@event_source(data_class=APIGatewayProxyEventV2)
def handler(event: APIGatewayProxyEventV2, context):
assert isinstance(event, APIGatewayProxyEventV2)
return app.resolve(event, context)

with pytest.warns(
UserWarning,
match="You don't need to serialize event to Event Source Data Class when using Event Handler",
):
return app.resolve(event, context)

# THEN
result = handler(load_event("apiGatewayProxyV2Event.json"), None)
Expand Down