Skip to content

Commit

Permalink
Perserve class in Collection.clone
Browse files Browse the repository at this point in the history
  • Loading branch information
duckontheweb committed Jul 2, 2021
1 parent 060f3c9 commit be548c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pystac/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,8 @@ def to_dict(self, include_self_link: bool = True) -> Dict[str, Any]:
return d

def clone(self) -> "Collection":
clone = Collection(
cls = self.__class__
clone = cls(
id=self.id,
description=self.description,
extent=self.extent.clone(),
Expand Down
6 changes: 6 additions & 0 deletions tests/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,3 +388,9 @@ def test_from_file_returns_subclass(self) -> None:
custom_collection = self.BasicCustomCollection.from_file(self.MULTI_EXTENT)

self.assertIsInstance(custom_collection, self.BasicCustomCollection)

def test_clone(self) -> None:
custom_collection = self.BasicCustomCollection.from_file(self.MULTI_EXTENT)
cloned_collection = custom_collection.clone()

self.assertIsInstance(cloned_collection, self.BasicCustomCollection)

0 comments on commit be548c6

Please sign in to comment.