def testGetStringForNonexistingLanguageFail(self): string = String('key', self.proper_languages) for lang in self.bad_languages: try: string.get(lang) self.fail('This operation should fail for language %s' % lang) except MstException: pass
def Wfunc(target, string, panel): print("send to:", target, "\nMsg is:", string) if panel == 0: target = target.get() string = string.get(1.0, "end-1c") if panel == 1 or panel == 0: try: group_title = driver.find_element_by_xpath( '//span[@title="' + target + '" and @class="_1wjpf"]') except NoSuchElementException: group_search = wait.until( EC.presence_of_element_located( (By.XPATH, '//*[@id="side"]/div[1]/div/label/input'))) group_search.send_keys(target) x_arg = '//span[@title="' + target + '"]' print(x_arg) group_title = wait.until( EC.element_to_be_clickable((By.XPATH, x_arg))) group_title.click() print("clicked.........") inp_xpath = '//div[@class="_2S1VP copyable-text selectable-text"][@dir="ltr"][@data-tab="1"]' input_box = wait.until( EC.presence_of_element_located((By.XPATH, inp_xpath))) input_box.send_keys(string) bts = driver.find_element_by_xpath( '//*[@id="main"]/footer/div[1]/div[3]/button') bts.click() elif panel == 2: inp_xpath = '//div[@class="_2S1VP copyable-text selectable-text"][@dir="ltr"][@data-tab="1"]' input_box = wait.until( EC.presence_of_element_located((By.XPATH, inp_xpath))) input_box.send_keys(string) bts = driver.find_element_by_xpath( '//*[@id="main"]/footer/div[1]/div[3]/button') bts.click()
def testAddTextForExistingLanguageSucceed(self): string = String('key', self.proper_languages) for lang in self.proper_languages: text = build_test_text(lang) string.add(lang, text) self.assertEqual(text, string.get(lang))
def testDefaultStringsEmpty(self): string = String('key', self.proper_languages) for lang in self.proper_languages: text = string.get(lang) self.assertEqual(text, '')
def testAddTextForExistingLanguageSucceed(self): string = String('key', self.proper_languages) for lang in self.proper_languages: text = build_test_text(lang) string.add(lang, text) self.assertEqual( text, string.get(lang) )
def process(): global filter_list fp2 = open('Parser_summary.html', 'w') num_records = 0 num_filtered_in = 0 num_hit = 0 # filter certain claims capability if (filter.get() != "None"): filter_list = build_filter_list(filter_list) print "filter status is:", filter.get() print filter_list # The tag by which we separate warranty Claims # p=re.compile('Machine Information', re.IGNORECASE) p = re.compile('<table>', re.IGNORECASE) # The tag by which we separate story within a warranty Claim # comment=re.compile('comment', re.IGNORECASE) comment = re.compile('<p>', re.IGNORECASE) searchlist = [] outputlist = [] fp2.write("##Searching file " + fp.name + "\n <br>Using Following Strings:") for string in strlist: chkstring = string.get() # The empty string check is sth I had add is python changed since 04 in what it returns? if ((chkstring != None) and (chkstring != "")): print "##using string", chkstring, " for search" searchlist.append(re.compile(string.get(), re.IGNORECASE)) fp2.write("\n<br>" + chkstring) line = fp.readline() # block to find the first Warranty tag and then the following while (line != ""): if p.match(line) != None: claim = [] buffer = [] claim.append(line) line = fp.readline() claim.append(line) while (p.match(line) == None) and (line != ""): claim.append(line) if (comment.match(line) != None): buffer.append(line) line = fp.readline() tmp_narrative = process_claim(claim) narrative = buffer + tmp_narrative num_records = num_records + 1 # Do any work only if the claim is not on filter list #print "Claim Number:", claim_num, "Filter Output:", to_be_filterd_in(filter_list,claim_num) if (to_be_filterd_in(filter_list, claim_num) == 1): num_filtered_in = num_filtered_in + 1 matchlist = search_narrative(narrative, searchlist) if (matchlist != []): output_line="\n <br>$$$$Current Record: "+repr(num_records)+\ " Claim Number:"+claim_num+"\n" num_hit = num_hit + 1 outputlist.append((num_records, claim_num, 1)) fp2.write(output_line) color_html(narrative, matchlist, fp2) else: outputlist.append((num_records, claim_num, 0)) if (raw_output.get() == 1): output_line="\n $$$$Current Record: "+repr(num_records)+\ " Claim Number:"+claim_num+"\n" #output_text.insert(Tkinter.END, output_line, "a") fp2.write(output_line) #for output_line in narrative: # output_text.insert(Tkinter.END, output_line,"normal") color_html(narrative, matchlist, fp2) else: line = fp.readline() else: #not close the line below so that we do not have open again and again #fp.close() fp.seek(0) output_line = "\n <br>Total Records: " + repr( num_records) + " Hits: " + repr(num_hit) output_text.insert(Tkinter.END, output_line) fp2.write(output_line) try: output_line="\n<br>Note this filters claims listed in: "+filter_file.name+\ "# Claims Filtered in:"+repr(num_filtered_in) fp2.write(output_line) except NameError: output_line = "" output_line = "\n <br>Matched Entries <br> " fp2.write(output_line) for j in range(len(outputlist)): if (outputlist[j][2] == 1): fp2.write("\n<br>" + outputlist[j][1])