Skip to content

Commit

Permalink
replace str() with repr() & test it (#1369) (#1473)
Browse files Browse the repository at this point in the history
  • Loading branch information
teks authored Nov 6, 2024
1 parent b052b2a commit 5b72d15
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pystac/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class StringEnum(str, Enum):
value."""

def __repr__(self) -> str:
return str(self.value)
return repr(self.value)

def __str__(self) -> str:
return cast(str, self.value)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pystac import utils
from pystac.utils import (
JoinType,
StringEnum,
is_absolute_href,
is_file_path,
join_path_or_url,
Expand Down Expand Up @@ -474,3 +475,10 @@ def test_join_path_or_url() -> None:
)
def test_is_file_path(href: str, expected: bool) -> None:
assert is_file_path(href) == expected


def test_stringenum_repr() -> None:
class SomeEnum(StringEnum):
THIS = "this"

assert repr(SomeEnum.THIS) == "'this'"

0 comments on commit 5b72d15

Please sign in to comment.