def test_find_different_struct_types(shmem): create_struct_with_offset_ptr_in_shared_memory(shmem, unique_instance, 10) create_struct_with_double_in_shared_memory(shmem, unique_instance) f1 = shmem.find(struct_with_offset_ptr, unique_instance) f2 = shmem.find(struct_with_double, unique_instance) assert type(f2) == struct_with_double assert type(f1) == struct_with_offset_ptr
def test_find_with_different_object_names(shmem): obj1 = create_struct_with_double_in_shared_memory(shmem, 'obj1') obj1.value = 1.5 obj2 = create_struct_with_double_in_shared_memory(shmem, 'obj2') obj2.value = 2.5 find_obj1 = shmem.find(struct_with_double, 'obj1') find_obj2 = shmem.find(struct_with_double, 'obj2') assert find_obj1.value == 1.5 assert find_obj2.value == 2.5
def test_find_with_struct_using_double(shmem): shmem = managed_shared_memory(open_or_create, 'MySharedMemory', 1024) original_struct = create_struct_with_double_in_shared_memory(shmem, unique_instance) original_struct.value = 1.5 find_struct = shmem.find(struct_with_double, unique_instance) assert find_struct.value == 1.5 original_struct.value = 2.5 assert find_struct.value == 2.5