def test_factory_func_remove(function_factory: FunctionFactoryBase): assert not function_factory.funcs_user initial_funcs_n = len(function_factory.funcs_inst) const_cls = function_factory.get('ConstFunc') f = const_cls(function_factory=function_factory, duration=4, a=.7, name='f') function_factory.add_func(f) f2 = const_cls(function_factory=function_factory, duration=4, a=.7, name='f2') function_factory.add_func(f2) assert len(function_factory.funcs_inst) == initial_funcs_n + 2 function_factory.test_changes_count = 0 assert function_factory.remove_func(f2) assert function_factory.test_changes_count assert f in function_factory.funcs_user assert f2 not in function_factory.funcs_user assert len(function_factory.funcs_user) == 1 assert f.name == 'f' assert f2.name == 'f2' assert function_factory.funcs_inst['f'] is f assert 'f2' not in function_factory.funcs_inst assert len(function_factory.funcs_inst) == initial_funcs_n + 1 function_factory.test_changes_count = 0 f2.name = 'f' assert not function_factory.test_changes_count assert f.name == 'f' assert f2.name == 'f' function_factory.test_changes_count = 0 assert function_factory.remove_func(f) assert function_factory.test_changes_count assert f not in function_factory.funcs_user assert f2 not in function_factory.funcs_user assert not function_factory.funcs_user assert f.name == 'f' assert f2.name == 'f' assert 'f' not in function_factory.funcs_inst assert 'f2' not in function_factory.funcs_inst assert len(function_factory.funcs_inst) == initial_funcs_n
def test_factory_func_unique_names(function_factory: FunctionFactoryBase): assert not function_factory.funcs_user function_factory.test_changes_count = 0 const_cls = function_factory.get('ConstFunc') f = const_cls(function_factory=function_factory, duration=4, a=.7, name='f') function_factory.add_func(f) f2 = const_cls(function_factory=function_factory, duration=4, a=.7, name='f') function_factory.add_func(f2) def assert_not_f(): assert function_factory.test_changes_count assert f in function_factory.funcs_user assert f2 in function_factory.funcs_user assert len(function_factory.funcs_user) == 2 f2_name = f2.name assert f.name == 'f' assert f2_name != 'f' assert f2_name assert function_factory.funcs_inst['f'] is f assert function_factory.funcs_inst[f2_name] is f2 assert_not_f() function_factory.test_changes_count = 0 f2.name = 'f2' assert function_factory.test_changes_count assert f in function_factory.funcs_user assert f2 in function_factory.funcs_user assert len(function_factory.funcs_user) == 2 assert f.name == 'f' assert f2.name == 'f2' assert function_factory.funcs_inst['f'] is f assert function_factory.funcs_inst['f2'] is f2 function_factory.test_changes_count = 0 f2.name = 'f' assert_not_f()
def test_register_user_func(function_factory: FunctionFactoryBase): assert not function_factory.funcs_user const_cls = function_factory.get('ConstFunc') f = const_cls(function_factory=function_factory, duration=4, a=.7, name='f') f2 = const_cls(function_factory=function_factory, duration=5, a=.9, name='f2') function_factory.test_changes_count = 0 function_factory.add_func(f) assert function_factory.test_changes_count assert f in function_factory.funcs_user assert function_factory.funcs_inst['f'] is f function_factory.test_changes_count = 0 function_factory.add_func(f2) assert function_factory.test_changes_count assert f2 in function_factory.funcs_user assert function_factory.funcs_inst['f2'] is f2
def test_clear_funcs(function_factory: FunctionFactoryBase): assert not function_factory.funcs_user initial_funcs_n = len(function_factory.funcs_inst) const_cls = function_factory.get('ConstFunc') f = const_cls(function_factory=function_factory, duration=4, a=.7, name='f') function_factory.add_func(f) f2 = const_cls(function_factory=function_factory, duration=4, a=.7, name='f2') function_factory.add_func(f2) assert len(function_factory.funcs_inst) == initial_funcs_n + 2 function_factory.test_changes_count = 0 function_factory.clear_added_funcs() assert len(function_factory.funcs_inst) == initial_funcs_n assert not function_factory.funcs_user