def tmp_atomspace(atomspace): parent_atomspace = atomspace atomspace = create_child_atomspace(parent_atomspace) initialize_opencog(atomspace) try: yield atomspace finally: atomspace.clear() finalize_opencog() initialize_opencog(parent_atomspace)
def tearDown(self): finalize_opencog() del self.space
result = bindlink(atomspace, bindlink_handle) assert_true(result is not None and result.value() > 0) # Check the ending atomspace size, it should have added one SetLink. ending_size = atomspace.size() assert_equals(ending_size, starting_size + 1) # The SetLink should have three items in it. atom = atomspace[result] assert_equals(atom.arity, 3) assert_equals(atom.type, types.SetLink) result = execute_atom(atomspace, ExecutionOutputLink( GroundedSchemaNode("py: add_link"), ListLink( ConceptNode("one"), ConceptNode("two") ) ) ) list_link = ListLink( ConceptNode("one"), ConceptNode("two") ) assert_equals(result, list_link) finalize_opencog() del atomspace
assert_true(result is not None) # Check the ending atomspace size, it should be the same. ending_size = atomspace.size() assert_equals(ending_size, starting_size) # Remember the starting atomspace size. starting_size = atomspace.size() # Run bindlink. result = bindlink(atomspace, bindlink_atom) assert_true(result is not None) # Check the ending atomspace size, it should have added one SetLink. ending_size = atomspace.size() assert_equals(ending_size, starting_size + 1) # The SetLink should have three items in it. assert_equals(result.arity, 3) assert_equals(result.type, types.SetLink) result = execute_atom( atomspace, ExecutionOutputLink(GroundedSchemaNode("py: add_link"), ListLink(ConceptNode("one"), ConceptNode("two")))) list_link = ListLink(ConceptNode("one"), ConceptNode("two")) assert_equals(result, list_link) finalize_opencog() del atomspace
def test_initialize_finalize(self): initialize_opencog(self.atomspace) finalize_opencog()
def remove(self): # make sure this is called by the time script exits finalize_opencog() del self.a
def tearDown(self): finalize_opencog()
def tearDownClass(cls): finalize_opencog() global atomspace del atomspace
def tearDown(self): self.atomspace = None finalize_opencog()
def delete_child_atomspace(): global child_atomspace child_atomspace.clear() finalize_opencog() initialize_opencog(atomspace)
def delete_child_atomspace(self): self.child_atomspace.clear() finalize_opencog() initialize_opencog(self.atomspace)