Skip to content

Commit 87eb1ad

Browse files
committed
Improve tests
1 parent a615938 commit 87eb1ad

File tree

4 files changed

+1428
-31
lines changed

4 files changed

+1428
-31
lines changed

pystac/extensions/classification.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def color_hint(self) -> Optional[str]:
159159
Returns:
160160
Optional[str]
161161
"""
162-
return self.properties.get("color_hint")
162+
return self.properties.get("color-hint")
163163

164164
@color_hint.setter
165165
def color_hint(self, v: Optional[str]) -> None:
@@ -169,9 +169,9 @@ def color_hint(self, v: Optional[str]) -> None:
169169
assert (
170170
v is None or match is not None and match.group() == v
171171
), "Must format color hints as '^([0-9A-F]{6})$'"
172-
self.properties["color_hint"] = v
172+
self.properties["color-hint"] = v
173173
else:
174-
self.properties.pop("color_hint", None)
174+
self.properties.pop("color-hint", None)
175175

176176
def to_dict(self) -> Dict[str, Any]:
177177
"""Returns the dictionary encoding of this class
@@ -181,11 +181,15 @@ def to_dict(self) -> Dict[str, Any]:
181181
"""
182182
return self.properties
183183

184-
def __eq__(self, other):
185-
return self.value == other.value and \
186-
self.description == other.description and \
187-
self.name == other.name and \
188-
self.color_hint == other.color_hint
184+
def __eq__(self, other: object) -> bool:
185+
if not isinstance(other, Classification):
186+
raise NotImplementedError
187+
return (
188+
self.value == other.value
189+
and self.description == other.description
190+
and self.name == other.name
191+
and self.color_hint == other.color_hint
192+
)
189193

190194
def __repr__(self) -> str:
191195
return f"<Classification value={self.value} description={self.description}>"
@@ -381,7 +385,7 @@ def name(self, v: Optional[str]) -> None:
381385
def __repr__(self) -> str:
382386
return (
383387
f"<Bitfield offset={self.offset} length={self.length} "
384-
"classes={self.classes}>"
388+
f"classes={self.classes}>"
385389
)
386390

387391
def to_dict(self) -> Dict[str, Any]:

0 commit comments

Comments
 (0)