How to use _convert_verdict method in green

Best Python code snippet using green

__init__.py

Source:__init__.py Github

copy

Full Screen

...78 except KeyError: oktests = None79 ans.append(bjtypes.submission_t(subm_id, task_id, status, score, oktests))80 return ans81 @staticmethod82 def _convert_verdict(s):83 s = s.replace('_', ' ')84 s = s[:1].upper()+s[1:].lower()85 if s == 'Correct':86 return 'OK'87 return s88 @staticmethod89 def _convert_stats(i):90 ans = {}91 if 'running_time_nanos' in i:92 ans['time_usage'] = i['running_time_nanos'] / 100000000093 if 'running_memory_mbs' in i:94 ans['memory_usage'] = i['running_memory_mbs'] * 104857695 return ans96 def _submission_descr(self, subm_id):97 subm_id = int(subm_id)98 data = self._get_which('attempts', "Failed to fetch submission list.")99 for i in data['attempts']:100 if int(i['id'], 16) == subm_id:101 return i102 return None103 def submission_protocol(self, subm_id):104 subm = self._submission_descr(subm_id)105 if subm == None: return []106 try: subm = subm['judgement']['results']107 except KeyError: return []108 return [bjtypes.test_t(self._convert_verdict(i['verdict__str']), self._convert_stats(i)) for i in subm]109 def submit_solution(self, task, lang, code):110 if isinstance(code, bytes): code = code.decode('utf-8', 'replace')111 self._json_req('https://codejam.googleapis.com/dashboard/%s/submit'%self.round, {'code': code, 'language_id': lang, 'task_id': '%016x'%task}, do_post=True)112 with self.cache_lock: self.stop_caching()113 def status(self):114 user_data = {}115 data = self._get_which('scoreboard', "Failed to fetch scoreboard.", {'num_consecutive_users': 0})116 for i in data['user_scores'][0]['task_info']:117 user_data[i['task_id']] = i['tests_definitely_solved'] + i['tests_possibly_solved']118 ans = collections.OrderedDict()119 for i in data['challenge']['tasks']:120 i_ = hex(int(i['id'], 16))[2:]121 st = None122 if i['id'] in user_data:123 st = 'OK' if user_data[i['id']] == sum(1 if j['value'] else 0 for j in i['tests']) else 'Partial solution'124 ans[i_] = st125 return ans126 def scores(self):127 user_data = {}128 data = self._get_which('scoreboard', "Failed to fetch scoreboard.", {'num_consecutive_users': 0})129 for i in data['user_scores'][0]['task_info']:130 user_data[i['task_id']] = i['score']131 ans = collections.OrderedDict()132 for i in data['challenge']['tasks']:133 i_ = hex(int(i['id'], 16))[2:]134 sc = None135 if i['id'] in user_data:136 sc = user_data[i['id']]137 ans[i_] = sc138 return ans139 def compile_error(self, subm_id):140 data = self._submission_descr(subm_id)141 if data == None: return None142 try: return data['judgement']['compilation_output']143 except KeyError: return None144 def _submission_status(self, subm):145 try: return self._convert_verdict(subm['judgement']['results'][-1]['verdict__str'])146 except KeyError: return 'Pending judgement'147 def submission_source(self, subm_id):148 data = self._submission_descr(subm_id)149 if data == None: return None150 return data['src_content'].encode('utf-8')151 def do_action(self, *args):152 raise BruteError("Actions are not supported on GCJ.")153 def compiler_list(self, task):154 return [bjtypes.compiler_t(i['id'], i['id__str'].lower(), i['name']) for i in self._get_dashboard("Failed to fetch compiler list.")['languages']]155 def _submission_stats(self, data, subm):156 for task in data['challenge']['tasks']:157 if int(task['id'], 16) == int(subm['task_id'], 16):158 break159 else: task = {}...

Full Screen

Full Screen

junit.py

Source:junit.py Github

copy

Full Screen

...115 xml_test = Element(JUnitDialect.TEST_CASE)116 xml_test.set(JUnitDialect.NAME, test.method_name)117 xml_test.set(JUnitDialect.CLASS_NAME, test.class_name)118 xml_test.set(JUnitDialect.TEST_TIME, test.test_time)119 xml_verdict = self._convert_verdict(verdict, test, details)120 if verdict:121 xml_test.append(xml_verdict)122 if test in results.stdout_output:123 system_out = Element(JUnitDialect.SYSTEM_OUT)124 system_out.text = results.stdout_output[test]125 xml_test.append(system_out)126 if test in results.stderr_errput:127 system_err = Element(JUnitDialect.SYSTEM_ERR)128 system_err.text = results.stderr_errput[test]129 xml_test.append(system_err)130 return xml_test131 def _convert_verdict(self, verdict, test, details):132 if verdict == Verdict.FAILED:133 failure = Element(JUnitDialect.FAILURE)134 failure.text = str(details[0])135 return failure136 if verdict == Verdict.ERROR:137 error = Element(JUnitDialect.ERROR)138 error.text = str(details[0])139 return error140 if verdict == Verdict.SKIPPED:141 skipped = Element(JUnitDialect.SKIPPED)142 skipped.text = str(details[0])143 return skipped144 return None145 @staticmethod...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run green automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful