Skip to content

Commit 5b72d15

Browse files
authored
replace str() with repr() & test it (#1369) (#1473)
1 parent b052b2a commit 5b72d15

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pystac/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class StringEnum(str, Enum):
8080
value."""
8181

8282
def __repr__(self) -> str:
83-
return str(self.value)
83+
return repr(self.value)
8484

8585
def __str__(self) -> str:
8686
return cast(str, self.value)

tests/test_utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pystac import utils
1111
from pystac.utils import (
1212
JoinType,
13+
StringEnum,
1314
is_absolute_href,
1415
is_file_path,
1516
join_path_or_url,
@@ -474,3 +475,10 @@ def test_join_path_or_url() -> None:
474475
)
475476
def test_is_file_path(href: str, expected: bool) -> None:
476477
assert is_file_path(href) == expected
478+
479+
480+
def test_stringenum_repr() -> None:
481+
class SomeEnum(StringEnum):
482+
THIS = "this"
483+
484+
assert repr(SomeEnum.THIS) == "'this'"

0 commit comments

Comments
 (0)