MCPcopy
hub / github.com/django/django / test_pickle

Method test_pickle

tests/gis_tests/geos_tests/test_geos.py:1455–1474  ·  view source on GitHub ↗

Testing pickling and unpickling support.

(self)

Source from the content-addressed store, hash-verified

1453 self.assertEqual((xmin, ymin, xmax, ymax), poly.extent)
1454
1455 def test_pickle(self):
1456 "Testing pickling and unpickling support."
1457
1458 # Creating a list of test geometries for pickling,
1459 # and setting the SRID on some of them.
1460 def get_geoms(lst, srid=None):
1461 return [GEOSGeometry(tg.wkt, srid) for tg in lst]
1462
1463 tgeoms = get_geoms(self.geometries.points)
1464 tgeoms.extend(get_geoms(self.geometries.multilinestrings, 4326))
1465 tgeoms.extend(get_geoms(self.geometries.polygons, 3084))
1466 tgeoms.extend(get_geoms(self.geometries.multipolygons, 3857))
1467 tgeoms.append(Point(srid=4326))
1468 tgeoms.append(Point())
1469 for geom in tgeoms:
1470 s1 = pickle.dumps(geom)
1471 g1 = pickle.loads(s1)
1472 with self.subTest(geom=geom):
1473 self.assertEqual(geom, g1)
1474 self.assertEqual(geom.srid, g1.srid)
1475
1476 def test_prepared(self):
1477 "Testing PreparedGeometry support."

Callers

nothing calls this directly

Calls 5

PointClass · 0.90
extendMethod · 0.80
appendMethod · 0.45
dumpsMethod · 0.45
loadsMethod · 0.45

Tested by

no test coverage detected