Skip to content

fix: Resolve error when creating EventError(...) with message=None #441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion linode_api4/polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class EventError(Exception):

def __init__(self, event_id: int, message: Optional[str]):
# Edge case, sometimes the message is populated with an empty string
if len(message) < 1:
if message is not None and len(message) < 1:
message = None

self.event_id = event_id
Expand Down
14 changes: 14 additions & 0 deletions test/unit/objects/polling_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,17 @@ def test_wait_for_event_finished_failed(
assert err.message == "oh no!"
else:
raise Exception("Expected event error, got none")

def test_event_error(
self,
):
"""
Tests that EventError objects can be constructed and
will be formatted to the correct output.

Tests for regression of TPT-3060
"""

assert str(EventError(123, None)) == "Event 123 failed"
assert str(EventError(123, "")) == "Event 123 failed"
assert str(EventError(123, "foobar")) == "Event 123 failed: foobar"