Ejemplo n.º 1
0
 def test_premature_attaching(self, empty_collection, plain_collection, n):
     for key, value in plain_collection.items():
         with pytest.raises(IncompleteSpecificationError):
             empty_collection._attach(DummyCppObj(),
                                      param_name="type_param",
                                      types=self.alphabet[:n])
         empty_collection[key] = value
     empty_collection._attach(DummyCppObj(),
                              param_name="type_param",
                              types=self.alphabet[:n])
Ejemplo n.º 2
0
def test_attaching(typedict_singleton_keys):
    sim = DummySimulation()
    cpp_obj = DummyCppObj()
    typedict_singleton_keys['A'] = dict(bar='first')
    typedict_singleton_keys['B'] = dict(bar='second')
    return AttachedTypeParameterDict(cpp_obj,
                                     param_name='type_param',
                                     type_kind='particle_types',
                                     type_param_dict=typedict_singleton_keys,
                                     sim=sim)
Ejemplo n.º 3
0
def test_apply_typeparam_dict(full_op):
    '''Tests _apply_typeparam_dict and by necessity getattr.'''
    full_op.type_param['A'] = dict(bar='world')
    full_op.type_param['B'] = dict(bar='hello')
    cpp_obj = DummyCppObj()
    full_op._cpp_obj = cpp_obj
    full_op._apply_typeparam_dict(cpp_obj, DummySimulation())
    assert cpp_obj.getTypeParam('A') == dict(foo=1, bar='world')
    assert cpp_obj.getTypeParam('B') == dict(foo=1, bar='hello')
    return full_op
Ejemplo n.º 4
0
def test_attach():
    triggered_op = DummyTriggeredOp(trigger=1)
    sim = DummySimulation()
    slist = SyncedList(lambda x: isinstance(x, DummyTriggeredOp),
                       lambda x: (x._cpp_obj, x.trigger))
    slist.append(triggered_op)
    triggered_op._cpp_obj = DummyCppObj()
    slist._sync(sim, sim._cpp_sys.dummy_list)
    assert len(sim._cpp_sys.dummy_list) == 1
    assert len(sim._cpp_sys.dummy_list[0]) == 2
    assert triggered_op._cpp_obj == sim._cpp_sys.dummy_list[0][0]
    assert triggered_op.trigger == sim._cpp_sys.dummy_list[0][1]
Ejemplo n.º 5
0
def test_attach(typeparam):
    return typeparam._attach(DummyCppObj(), DummySimulation().state)
Ejemplo n.º 6
0
 def populated_collection(self, empty_collection, plain_collection, n):
     empty_collection.update(plain_collection)
     empty_collection._attach(DummyCppObj(),
                              param_name="type_param",
                              types=self.alphabet[:n])
     return empty_collection, plain_collection