def test_afw_union_intersecting(self): """ Tests a correct afw union where the afws have some state in common """ AFW.rename_afw_states(self.afw_union_3_test_01, 'a_') union = AFW.afw_union(self.afw_union_1_test_01, self.afw_union_3_test_01) i = 0 last = 7 while i <= last: base = list(itertools.repeat('a', i)) base += list(itertools.repeat('b', i)) # build all permutation of 'a' and 'b' till length i word_set = set(itertools.permutations(base, i)) for word in word_set: word = list(word) # print(word) original_acceptance_1 = AFW.afw_word_acceptance( self.afw_union_1_test_01, word) original_acceptance_2 = AFW.afw_word_acceptance( self.afw_union_3_test_01, word) union_acceptance = AFW.afw_word_acceptance(union, word) self.assertEqual( original_acceptance_1 or original_acceptance_2, union_acceptance) i += 1
def test_afw_union_empty_states_2(self): """ Tests a afw union where the second afw is empty """ union = AFW.afw_union(self.afw_union_1_test_01, self.afw_union_test_empty) i = 0 last = 7 while i <= last: base = list(itertools.repeat('a', i)) base += list(itertools.repeat('b', i)) # build all permutation of 'a' and 'b' till length i word_set = set(itertools.permutations(base, i)) for word in word_set: word = list(word) original_acceptance_1 = AFW.afw_word_acceptance( self.afw_union_1_test_01, word) original_acceptance_2 = AFW.afw_word_acceptance( self.afw_union_test_empty, word) union_acceptance = AFW.afw_word_acceptance(union, word) self.assertEqual( original_acceptance_1 or original_acceptance_2, union_acceptance) i += 1
def test_afw_union_disjoint(self): """ Tests a correct afw union with completely disjoint afws """ AFW.rename_afw_states(self.afw_union_2_test_01, 'a_') union = AFW.afw_union(self.afw_union_1_test_01, self.afw_union_2_test_01) i = 0 last = 7 while i <= last: base = list(itertools.repeat('a', i)) base += list(itertools.repeat('b', i)) # build all permutation of 'a' and 'b' till length i word_set = set(itertools.permutations(base, i)) for word in word_set: word = list(word) original_acceptance_1 = AFW.afw_word_acceptance( self.afw_union_1_test_01, word) original_acceptance_2 = AFW.afw_word_acceptance( self.afw_union_2_test_01, word) union_acceptance = AFW.afw_word_acceptance(union, word) self.assertEqual( original_acceptance_1 or original_acceptance_2, union_acceptance) i += 1
def test_afw_union_side_effects_2(self): """ Tests the function makes side effect on the second input """ before = copy.deepcopy(self.afw_union_2_test_01) AFW.afw_union(self.afw_union_1_test_01, self.afw_union_2_test_01) self.assertEqual(before, self.afw_union_2_test_01)
def test_afw_union_wrong_dict_2(self): """ Tests a dict() in input different from a well formatted dict() representing a AFW. [EXPECTED FAILURE]""" AFW.afw_union({'goofy': 'donald'}, self.afw_union_1_test_01)
def test_afw_union_wrong_input_2(self): """ Tests an input different from a dict() object. [EXPECTED FAILURE]""" AFW.afw_union(self.afw_union_1_test_01, 0)