MCPcopy
hub / github.com/django/django / _test_buffer

Method _test_buffer

tests/gis_tests/geos_tests/test_geos.py:938–968  ·  view source on GitHub ↗
(self, geometries, buffer_method_name)

Source from the content-addressed store, hash-verified

936 )
937
938 def _test_buffer(self, geometries, buffer_method_name):
939 for bg in geometries:
940 g = fromstr(bg.wkt)
941
942 # The buffer we expect
943 exp_buf = fromstr(bg.buffer_wkt)
944
945 # Constructing our buffer
946 buf_kwargs = {
947 kwarg_name: getattr(bg, kwarg_name)
948 for kwarg_name in (
949 "width",
950 "quadsegs",
951 "end_cap_style",
952 "join_style",
953 "mitre_limit",
954 )
955 if hasattr(bg, kwarg_name)
956 }
957 buf = getattr(g, buffer_method_name)(**buf_kwargs)
958 with self.subTest(bg=bg):
959 self.assertEqual(exp_buf.num_coords, buf.num_coords)
960 self.assertEqual(len(exp_buf), len(buf))
961
962 # Now assuring that each point in the buffer is almost equal
963 for exp_ring, buf_ring in zip(exp_buf, buf, strict=True):
964 for exp_point, buf_point in zip(exp_ring, buf_ring, strict=True):
965 # Asserting the X, Y of each point are almost equal
966 # (due to floating point imprecision).
967 self.assertAlmostEqual(exp_point[0], buf_point[0], 9)
968 self.assertAlmostEqual(exp_point[1], buf_point[1], 9)
969
970 def test_covers(self):
971 poly = Polygon(((0, 0), (0, 10), (10, 10), (10, 0), (0, 0)))

Callers 2

test_bufferMethod · 0.95

Calls 1

fromstrFunction · 0.90

Tested by

no test coverage detected