GEOSGeometry subclass may itself be subclassed without being forced-cast to the parent class during `__init__`.
(self)
| 1620 | self.assertEqual(kwargs, {}) |
| 1621 | |
| 1622 | def test_subclassing(self): |
| 1623 | """ |
| 1624 | GEOSGeometry subclass may itself be subclassed without being |
| 1625 | forced-cast to the parent class during `__init__`. |
| 1626 | """ |
| 1627 | |
| 1628 | class ExtendedPolygon(Polygon): |
| 1629 | def __init__(self, *args, data=0, **kwargs): |
| 1630 | super().__init__(*args, **kwargs) |
| 1631 | self._data = data |
| 1632 | |
| 1633 | def __str__(self): |
| 1634 | return "EXT_POLYGON - data: %d - %s" % (self._data, self.wkt) |
| 1635 | |
| 1636 | ext_poly = ExtendedPolygon(((0, 0), (0, 1), (1, 1), (0, 0)), data=3) |
| 1637 | self.assertEqual(type(ext_poly), ExtendedPolygon) |
| 1638 | # ExtendedPolygon.__str__ should be called (instead of |
| 1639 | # Polygon.__str__). |
| 1640 | self.assertEqual( |
| 1641 | str(ext_poly), "EXT_POLYGON - data: 3 - POLYGON ((0 0, 0 1, 1 1, 0 0))" |
| 1642 | ) |
| 1643 | self.assertJSONEqual( |
| 1644 | ext_poly.json, |
| 1645 | '{"coordinates": [[[0, 0], [0, 1], [1, 1], [0, 0]]], "type": "Polygon"}', |
| 1646 | ) |
| 1647 | |
| 1648 | def test_geos_version_tuple(self): |
| 1649 | versions = ( |
nothing calls this directly
no test coverage detected