Skip to content

Commit

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

def clone(self) -> "Catalog":
clone = Catalog(
cls = self.__class__
clone = cls(
id=self.id,
description=self.description,
title=self.title,
Expand Down
6 changes: 6 additions & 0 deletions tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,3 +1153,9 @@ def test_from_file_returns_subclass(self) -> None:
custom_catalog = self.BasicCustomCatalog.from_file(self.TEST_CASE_1)

self.assertIsInstance(custom_catalog, self.BasicCustomCatalog)

def test_clone(self) -> None:
custom_catalog = self.BasicCustomCatalog.from_file(self.TEST_CASE_1)
cloned_catalog = custom_catalog.clone()

self.assertIsInstance(cloned_catalog, self.BasicCustomCatalog)

0 comments on commit 060f3c9

Please sign in to comment.