Best Python code snippet using tox_python
project_task_merge_wizard.py
Source:project_task_merge_wizard.py
...11 @api.multi12 def merge_tasks(self):13 values = {14 'user_id': self.user_id.id,15 'description': self.merge_description(),16 }17 if self.create_new_task:18 values.update({19 'name': self.target_task_name,20 'project_id': self.target_project_id.id21 })22 self.target_task_id = self.env['project.task'].create(values)23 else:24 self.target_task_id.write(values)25 self.merge_followers()26 self.target_task_id.message_post_with_view(27 self.env.ref('project.mail_template_task_merge'),28 values={'target': True, 'tasks': self.task_ids - self.target_task_id},29 subtype_id=self.env.ref('mail.mt_comment').id30 )31 (self.task_ids - self.target_task_id).message_post_with_view(32 self.env.ref('project.mail_template_task_merge'),33 values={'target': False, 'task': self.target_task_id},34 subtype_id=self.env.ref('mail.mt_comment').id35 )36 (self.task_ids - self.target_task_id).write({'active': False})37 return {38 "type": "ir.actions.act_window",39 "res_model": "project.task",40 "views": [[False, "form"]],41 "res_id": self.target_task_id.id,42 }43 @api.multi44 def merge_description(self):45 return '<br/>'.join(self.task_ids.mapped(lambda task: "Description from task <b>%s</b>:<br/>%s" % (task.name, task.description or 'No description')))46 @api.multi47 def merge_followers(self):48 self.target_task_id.message_subscribe(49 partner_ids=(self.task_ids - self.target_task_id).mapped('message_partner_ids').ids,50 channel_ids=(self.task_ids - self.target_task_id).mapped('message_channel_ids').ids,51 )52 @api.model53 def default_get(self, fields):54 result = super(ProjectTaskMergeWizard, self).default_get(fields)55 selected_tasks = self.env['project.task'].browse(self.env.context.get('active_ids', False))56 assigned_tasks = selected_tasks.filtered(lambda task: task.user_id)57 result.update({58 'task_ids': selected_tasks.ids,...
listr.py
Source:listr.py
1import getpass2import re3def merge_description(li, str=''):4 for i in range(len(li)):5 str = str+'_'+li[i]6 return str[1:]7def final_li(all_result_list, splitstr, tc_list, tc_full_list):8 for item in all_result_list:9 tc_list.append(item[len(splitstr):])10 none_preconditioncode = []11 for i in tc_list:12 if len(i.split(splitstr)) < 5:13 print('>>> Dump: %s\n Reason: Route too short' % (i))14 elif '#' in i:15 print('>>> Dump: %s\n Reason: Manually Abandoned' % (i))16 else:17 tmpli = []18 # åè½è·¯å¾19 tc_funcpath = i.split(splitstr)[:1]20 # åè½ç¹21 tc_point = i.split(splitstr)[1:2]22 # åè½è¯´æ23 tc_description = i.split(splitstr)[2:-3]24 # æ¥æº25 tc_source = 'éæ±ææ¡£'26 # åç½®æ¡ä»¶27 try:28 tc_preconditions = i.split(splitstr)[-3]29 except IndexError as e:30 print(e)31 # å¹é
å个大åæå°ååæ¯ãä¸ä¸ªæ两个æ°åãä¸ä¸ªåæ¯åä¸ä¸ªæ°åç»åãä¸ä¸ªæ°åååæ¯ç»å32 if re.match('^[a-zA-Z]{1}$|^[0-9]{1,2}$|^[a-zA-z]{1}[0-9]{1}$|^[0-9]{1}[a-zA-z]{1}$', i.split(splitstr)[-3]):33 if len(i.split(splitstr)[-3]) < 2:34 tc_preconditions = '%s0æ°æ®åå¤ï¼æ ' % (i.split(splitstr)[-3])35 else:36 tc_preconditions = '%sæ°æ®åå¤ï¼æ ' % (i.split(splitstr)[-3])37 # elif i.split(splitstr)[-3] == 'æ ':38 # tc_preconditions = 'æ°æ®åå¤ï¼æ '39 else:40 tc_preconditions = 'æ°æ®åå¤ï¼%s' % (i.split(splitstr)[-3])41 # input42 tc_input = 'input: %s' % (i.split(splitstr)[-2])43 # output44 tc_output = 'output: %s' % (i.split(splitstr)[-1])45 # ç¨ä¾çº§å«46 # TODO è·åèå¾ä¸çç¨ä¾çº§å«47 tc_level = '0级'48 # ç¨ä¾è´£ä»»äºº49 tc_tester = getpass.getuser()50 # éç¨çæ¬51 tc_version = 'v3.0'52 tmpli.append(tc_funcpath[0])53 tmpli.append(tc_point[0])54 tmpli.append(merge_description(tc_description))55 tmpli.append(tc_source)56 tmpli.append(tc_preconditions)57 tmpli.append(tc_input)58 tmpli.append(tc_output)59 tmpli.append(tc_level)60 tmpli.append(tc_tester)61 tmpli.append(tc_version)62 tc_full_list.append(tmpli)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!