def test_who_fluency(self, mock_tokenize): testarray = [] testarray.append("that student is the one who studies computer science") askfunc.removeQuestions(testarray) self.assertTrue(not mock_tokenize.called)
questionarray.append(qstring.strip()) for m in re.finditer("is the .{,20} of .{5,30}\.",text): endq=m.group(0)[:len(m.group(0))-1] questionarray.append('What %s?' % (endq)) f.seek(0) '''for line in f: for m in re.finditer("[A-Z].{,50} is (.{,30})[/./,/;]",line): if re.match("[A-Z].{,50} is (.{,30})[/./,/;]",line): isq=m.group(0) isq=isq.replace(isq[0],isq[0].lower()) isq=isq.replace(' is ',' ') questionarray.append('Is %s?' % (isq[0:len(isq)-1]))''' askfunc.removeQuestions(questionarray) for line in f: for m in re.finditer("[1-2]{0,1}[0-9]\s((January)|(February)|(March)|(April)|(May)|(June)|(July)|(August)|(September)|(October)|(November)|(December))\s([0-2][0-9][0-9][0-9])",line): if re.search("[1-2]{0,1}[0-9]\s((January)|(February)|(March)|(April)|(May)|(June)|(July)|(August)|(September)|(October)|(November)|(December))\s([0-2][0-9][0-9][0-9])",line): date=m.group(0) year=date[-4:] year=pronounce.pronounce_year(year) if re.match("[10-31]",date): day=date[:2] day='the '+pronounce.pronounce_day(day).lower()+' of' date=day+date[2:] else: day=date[0] day='the '+pronounce.pronounce_day(day)+' of' date=day+date[1:]
def test_keep_question(self): testarray = [] testarray.append("that student studies computer science") askfunc.removeQuestions(testarray) self.assertTrue(len(testarray) == 1)
def test_remove_who(self): testarray = [] testarray.append("that student is the one who studies computer science") askfunc.removeQuestions(testarray) self.assertTrue(len(testarray) == 0)
def test_remove_over(self, mock_getfluency): testarray = [] testarray.append("one two three four five six seven eight nine ten eleven") askfunc.removeQuestions(testarray) mock_getfluency.assert_called()
def test_remove_equal(self, mock_getfluency): testarray = [] testarray.append("one two three four five six seven eight nine ten") askfunc.removeQuestions(testarray) assert not mock_getfluency.called, "Get fluency was called even though "
def test_remove_under(self, mock_getfluency): testarray = [] testarray.append("one two three four five") askfunc.removeQuestions(testarray) mock_getfluency.assert_called()