MCPcopy
hub / github.com/django/django / test_linearring

Method test_linearring

tests/gis_tests/geos_tests/test_geos.py:572–605  ·  view source on GitHub ↗

Testing LinearRing objects.

(self)

Source from the content-addressed store, hash-verified

570 )
571
572 def test_linearring(self):
573 "Testing LinearRing objects."
574 for rr in self.geometries.linearrings:
575 lr = fromstr(rr.wkt)
576 with self.subTest(rr=rr):
577 self.assertEqual(lr.geom_type, "LinearRing")
578 self.assertEqual(lr.geom_typeid, 2)
579 self.assertEqual(lr.dims, 1)
580 self.assertEqual(rr.n_p, len(lr))
581 self.assertIs(lr.valid, True)
582 self.assertIs(lr.empty, False)
583
584 # Creating a LinearRing from a tuple, list, and numpy array
585 self.assertEqual(lr, LinearRing(lr.tuple))
586 self.assertEqual(lr, LinearRing(*lr.tuple))
587 self.assertEqual(lr, LinearRing([list(tup) for tup in lr.tuple]))
588 if numpy:
589 self.assertEqual(lr, LinearRing(numpy.array(lr.tuple)))
590
591 with self.assertRaisesMessage(
592 ValueError, "LinearRing requires at least 4 points, got 3."
593 ):
594 LinearRing((0, 0), (1, 1), (0, 0))
595
596 with self.assertRaisesMessage(
597 ValueError, "LinearRing requires at least 4 points, got 1."
598 ):
599 LinearRing([(0, 0)])
600
601 if numpy:
602 with self.assertRaisesMessage(
603 ValueError, "LinearRing requires at least 4 points, got 1."
604 ):
605 LinearRing(numpy.array([(0, 0)]))
606
607 def test_linearring_json(self):
608 self.assertJSONEqual(

Callers

nothing calls this directly

Calls 4

fromstrFunction · 0.90
LinearRingClass · 0.90
arrayMethod · 0.80
assertRaisesMessageMethod · 0.80

Tested by

no test coverage detected