def test_collman_aarects(variant, ctor_args, offset):
    emptyset = set()
    (center_aarect, ring_touching, ring_near, ring_far,
     near_distance, far_distance, rays) = aarect_circle_data1(eu.Vector2(*offset))

    collman_cls = getattr(cm, variant)
    collman = collman_cls(*ctor_args)

    collman.add(center_aarect)
    for ring in [ ring_touching, ring_near, ring_far ]:
        for circle in ring:
            collman.add(circle)

    # all objs in data1 are known
    assert collman.knows(center_aarect)
    for ring in [ ring_touching, ring_near, ring_far ]:
        for circle in ring:
            collman.knows(circle)

    # the set of know objects is exactly the set of objects in data1
    assert collman.known_objs() == (set([center_aarect]) | ring_touching |
                                  ring_near | ring_far) 

    touching_result = collman.objs_colliding(center_aarect)

    # no repetitions
    touching = set(touching_result)
    assert len(touching) == len(touching_result)

    # obj is not in objs_colliding_with(obj)
    assert center_aarect not in touching

    # any in ring_touching is touching
    assert ring_touching <= touching

    # none of ring_near touches
    assert (ring_near & touching) == emptyset

    # none of ring_far touches
    assert (ring_far & touching) == emptyset

    # no extraneous values in touching
    assert ring_touching == touching

    # the generator form of touching gives same result than objs_colliding
    touching_from_generator = [e for e in collman.iter_colliding(center_aarect)]
    assert len(touching_from_generator) == len(touching)
    assert set(touching_from_generator) == touching


    # test with short near_distance, should be same as before
    short_distance = 0.9 * near_distance
    nears1_result = collman.objs_near(center_aarect, short_distance)
    #  no repetitions
    nears1 = set(nears1_result)
    assert len(nears1) == len(nears1_result)
    #  expected due to short near_distance
    assert nears1 == ring_touching

    # similar using objs_near_wdistance
    od_list = collman.objs_near_wdistance(center_aarect, short_distance)
    assert len(od_list) == len(ring_touching)
    assert set([a for a,b in od_list]) == ring_touching
    # and distances are near 0.0
    for a,d in od_list:
        assert abs(d-0.0)<fe

    # test with near distance to accept ring_near and reject ring_far
    n_distance = 0.9*near_distance + 0.1*far_distance
    nears2 = set(collman.objs_near(center_aarect, n_distance))
    assert (ring_far & nears2) == emptyset
    ##pprint_container('nears2:', nears2)
    ##pprint_container('ring_touching | ring_near', ring_touching | ring_near)
    assert nears2 == (ring_touching | ring_near)

    # similar using objs_near_wdistance
    od_list = collman.objs_near_wdistance(center_aarect, n_distance)
    nears2 = set(od_list)
    assert len(od_list) == len(nears2)
    assert set([a for a,b in od_list]) == (ring_touching | ring_near)
    # and distances match
    for a,d in od_list:
        assert ((a in ring_touching and abs(d) < fe) or
                (a in ring_near and abs(d-near_distance)<fe))

    # all_collisions
    li_touching_center = []
    d = {}
    for ray in rays:
        d[" ray %2d"%ray] = []
    
    for obj, other in collman.iter_all_collisions():
        # no collision with itself
        assert obj is not other
        # collision touching center
        if obj.name == 'center' or other.name == 'center':
            if obj.name == 'center':
                li_touching_center.append(other)
            else:
                li_touching_center.append(obj)
        else:
            # collisions not touching center
            obj_ring, obj_distance, obj_ray = obj.name.split(',')
            other_ring, other_distance, other_ray = obj.name.split(',')
            assert obj_ray == other_ray
            assert obj_ray in d
            if id(obj)>id(other):
                obj, other = other, obj
            d[obj_ray].append((obj, other))

    #      the ones touching center are correct
    assert len(li_touching_center) == len(touching)
    assert set(li_touching_center) == touching

    #      all the others
    for k in d:
        # no repetitions
        li = d[k]; si = set(li)
        assert len(li) == len(si)
        # all collisions for the ray
        assert len(si) == 2
    

    # removing center_aarect
    collman.remove_tricky(center_aarect)
    assert not collman.knows(center_aarect)
    assert center_aarect not in collman.known_objs()
    assert collman.known_objs() == (ring_touching | ring_near | ring_far)

    # any_near, with obj not known
    rx = center_aarect.cshape.rx
    ry = center_aarect.cshape.ry
    small = create_obj_with_aarect('small', center_aarect.cshape.center,
                                rx - near_distance*2.0, ry - near_distance*2.0)
    #   param 'near_distance' selected to obtain return None
    assert collman.any_near(small, near_distance/2.0) is None

    #   param 'near_distance' selected to obtain  a known object (weak)
    assert collman.any_near(small, near_distance*2.1) is not None

    # any near with known object
    collman.add(small)
    assert collman.any_near(small, near_distance/2.0) is None
    


#plot_aarect_circle_data1(eu.Vector2(0.0, 0.0))
Tests collision manager basic behavoir when shape is AARectShape,
dataset/ETHPy150Open los-cocos/cocos/utest/test_collision_model_aarect_circle.py/test_collman_aarects