Skip to content

Commit

Permalink
Fix error when creating EventError(...) with message=None (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarber-akamai authored Jul 25, 2024
1 parent 06f72c1 commit d04a1a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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"

0 comments on commit d04a1a1

Please sign in to comment.