Make mypy work again #8
2 changed files with 10 additions and 0 deletions
Raise an error if Path._directions is not set ...
... instead of failing inside `json.loads()` on `None`
commit
607055d55a
|
|
@ -270,6 +270,9 @@ class Path(meta.Base):
|
|||
Implementation detail: This property is cached as none of the
|
||||
underlying attributes (i.e., `._directions`) are to be changed.
|
||||
"""
|
||||
if not self._directions:
|
||||
raise RuntimeError("_directions is not set")
|
||||
|
||||
points = [utils.Location(*point) for point in json.loads(self._directions)]
|
||||
for point in points:
|
||||
point.relate_to(self.first_address.city.southwest)
|
||||
|
|
|
|||
|
|
@ -670,6 +670,13 @@ class TestSyncWithGoogleMaps:
|
|||
class TestProperties:
|
||||
"""Test properties in `Path`."""
|
||||
|
||||
def test_waypoints_no_directions(self, path):
|
||||
"""Test `Path.waypoints` property."""
|
||||
path._directions = None
|
||||
|
||||
with pytest.raises(RuntimeError, match="not set"):
|
||||
int(path.waypoints)
|
||||
|
||||
def test_waypoints_structure(self, path):
|
||||
"""Test `Path.waypoints` property."""
|
||||
result = path.waypoints
|
||||
|
|
|
|||
Loading…
Reference in a new issue