test_nearest.py 476 B

123456789101112131415161718
  1. import unittest
  2. import pytest
  3. from shapely.geometry import Point
  4. from shapely.ops import nearest_points
  5. class Nearest(unittest.TestCase):
  6. def test_nearest(self):
  7. first, second = nearest_points(
  8. Point(0, 0).buffer(1.0),
  9. Point(3, 0).buffer(1.0),
  10. )
  11. assert first.x == pytest.approx(1.0)
  12. assert second.x == pytest.approx(2.0)
  13. assert first.y == pytest.approx(0.0)
  14. assert second.y == pytest.approx(0.0)