def edge(self, f, a, b, s): print('Symbol: ', s) # edge creates a new edge on the trie. if not ( isinstance(f, str) and isinstance(a, str) and isinstance(b, str) and isinstance(s, str)): raise TypeError('ERROR: Edge requires string arguments.') elif f in self.A: raise ValueError('ERROR: Edge name already taken.') elif not trie_methods.is_gen(s): raise ValueError('ERROR: Edge requires a dna char for symbol.') else: self.A.append(f) self.dom[f] = a self.cod[f] = b self.sym[f] = s
def test_true(self): s = 'cga' val = trie_methods.is_gen(s) self.assertTrue(val)
def test_false(self): s = 'tge' val = trie_methods.is_gen(s) self.assertFalse(val)
def test_not_string(self): s = None with self.assertRaises(TypeError): trie_methods.is_gen(s)