'Testing the mutability of Polygons and Geometry Collections.'

def test_mutable_geometries(self):

    for p in self.geometries.polygons:
        poly = fromstr(p.wkt)
        self.assertRaises(TypeError, poly.__setitem__, 0, LineString((1, 1), (2, 2)))
        shell_tup = poly.shell.tuple
        new_coords = []
        for point in shell_tup:
            new_coords.append(((point[0] + 500.0), (point[1] + 500.0)))
        new_shell = LinearRing(*tuple(new_coords))
        poly.exterior_ring = new_shell
        s = str(new_shell)
        self.assertEqual(poly.exterior_ring, new_shell)
        self.assertEqual(poly[0], new_shell)
    for tg in self.geometries.multipoints:
        mp = fromstr(tg.wkt)
        for i in range(len(mp)):
            pnt = mp[i]
            new = Point(random.randint(21, 100), random.randint(21, 100))
            mp[i] = new
            s = str(new)
            self.assertEqual(mp[i], new)
            self.assertEqual(mp[i].wkt, new.wkt)
            self.assertNotEqual(pnt, mp[i])
    for tg in self.geometries.multipolygons:
        mpoly = fromstr(tg.wkt)
        for i in xrange(len(mpoly)):
            poly = mpoly[i]
            old_poly = mpoly[i]
            for j in xrange(len(poly)):
                r = poly[j]
                for k in xrange(len(r)):
                    r[k] = ((r[k][0] + 500.0), (r[k][1] + 500.0))
                poly[j] = r
            self.assertNotEqual(mpoly[i], poly)
            mpoly[i] = poly
            s = str(poly)
            self.assertEqual(mpoly[i], poly)
            self.assertNotEqual(mpoly[i], old_poly)
