from . import unittest
from shapely.geometry import LineString
from shapely.geometry.collection import GeometryCollection


class CollectionTestCase(unittest.TestCase):

    def test_array_interface(self):
        m = GeometryCollection()
        self.assertEqual(len(m), 0)
        self.assertEqual(m.geoms, [])

    def test_child_with_deleted_parent(self):
        # test that we can remove a collection while having
        # childs around
        a = LineString([(0, 0), (1, 1), (1, 2), (2, 2)])
        b = LineString([(0, 0), (1, 1), (2, 1), (2, 2)])
        collection = a.intersection(b)

        child = collection.geoms[0]
        # delete parent of child
        del collection

        # access geometry, this should not seg fault as 1.2.15 did
        self.assertIsNotNone(child.wkt)


def test_suite():
    return unittest.TestLoader().loadTestsFromTestCase(CollectionTestCase)

@@ -115,16 +115,88 @@
 lection%0A
+from shapely.geometry import shape%0Afrom shapely.geometry import asShape%0A
 %0A%0Aclass 
@@ -864,16 +864,1260 @@
 d.wkt)%0A%0A
+    def test_geointerface(self):%0A        d = %7B%22type%22: %22GeometryCollection%22,%22geometries%22: %5B%0A                %7B%22type%22: %22Point%22, %22coordinates%22: (0, 3)%7D,%0A                %7B%22type%22: %22LineString%22, %22coordinates%22: ((2, 0), (1, 0))%7D%0A            %5D%7D%0A%0A        # asShape%0A        m = asShape(d)%0A        self.assertEqual(m.geom_type, %22GeometryCollection%22)%0A        self.assertEqual(len(m), 2)%0A        geom_types = %5Bg.geom_type for g in m.geoms%5D%0A        self.assertIn(%22Point%22, geom_types)%0A        self.assertIn(%22LineString%22, geom_types)%0A%0A        # shape%0A        m = shape(d)%0A        self.assertEqual(m.geom_type, %22GeometryCollection%22)%0A        self.assertEqual(len(m), 2)%0A        geom_types = %5Bg.geom_type for g in m.geoms%5D%0A        self.assertIn(%22Point%22, geom_types)%0A        self.assertIn(%22LineString%22, geom_types)%0A%0A    def test_empty_geointerface(self):%0A        d = %7B%22type%22: %22GeometryCollection%22, %22geometries%22: %5B%5D%7D%0A%0A        # asShape%0A        m = asShape(d)%0A        self.assertEqual(m.geom_type, %22GeometryCollection%22)%0A        self.assertEqual(len(m), 0)%0A        self.assertEqual(m.geoms, %5B%5D)%0A%0A        # shape%0A        m = shape(d)%0A        self.assertEqual(m.geom_type, %22GeometryCollection%22)%0A        self.assertEqual(len(m), 0)%0A        self.assertEqual(m.geoms, %5B%5D)%0A%0A
 %0Adef tes

Add tests for geointerface of GeometryCollection