

def test_geojson_PolygonField(self):

    class Location(Document):
        poly = PolygonField()
    Location.drop_collection()
    Location(poly=[[[40, 5], [40, 6], [41, 6], [40, 5]]]).save()
    loc = Location.objects.as_pymongo()[0]
    self.assertEqual(self['poly'], {
        'type': 'Polygon',
        'coordinates': [[[40, 5], [40, 6], [41, 6], [40, 5]]],
    })
    Location.objects.update(set__poly=[[[40, 4], [40, 6], [41, 6], [40, 4]]])
    loc = Location.objects.as_pymongo()[0]
    self.assertEqual(loc['poly'], {
        'type': 'Polygon',
        'coordinates': [[[40, 4], [40, 6], [41, 6], [40, 4]]],
    })

dataset/ETHPy150Open MongoEngine/mongoengine/tests/queryset/geo.py GeoQueriesTest.test_geojson_PolygonField/VarMisuse@86/96 `loc`->`self`