Skip to content

Commit 060f3c9

Browse files
committed
Perserve class in Catalog.clone
1 parent 9ddfd26 commit 060f3c9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pystac/catalog.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,8 @@ def to_dict(self, include_self_link: bool = True) -> Dict[str, Any]:
471471
return d
472472

473473
def clone(self) -> "Catalog":
474-
clone = Catalog(
474+
cls = self.__class__
475+
clone = cls(
475476
id=self.id,
476477
description=self.description,
477478
title=self.title,

tests/test_catalog.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,3 +1153,9 @@ def test_from_file_returns_subclass(self) -> None:
11531153
custom_catalog = self.BasicCustomCatalog.from_file(self.TEST_CASE_1)
11541154

11551155
self.assertIsInstance(custom_catalog, self.BasicCustomCatalog)
1156+
1157+
def test_clone(self) -> None:
1158+
custom_catalog = self.BasicCustomCatalog.from_file(self.TEST_CASE_1)
1159+
cloned_catalog = custom_catalog.clone()
1160+
1161+
self.assertIsInstance(cloned_catalog, self.BasicCustomCatalog)

0 commit comments

Comments
 (0)