Best Python code snippet using stestr_python
testrail_helper.py
Source:testrail_helper.py
...55 False, test_cases, config_ids, runs)56 run_id = str(self.get_run_id_by_name(suite_name, plan_entry))57 os.environ['test_rail_run_id'] = run_id # For parallel execution58 return run_id59 def get_test_ids(self, test_case):60 marker = test_case.get_closest_marker('test_id')61 if marker:62 return marker.args63 return None64 def get_result_from_string(self, str_result: str) -> TestCaseStatuses:65 if str_result == 'passed':66 return TestCaseStatuses.PASSED67 elif str_result == 'failed':68 return TestCaseStatuses.FAILED69 elif str_result == 'flaky':70 return TestCaseStatuses.FLAKY71 elif str_result == 'broken':72 return TestCaseStatuses.BROKEN73 elif str_result == 'skipped':74 return TestCaseStatuses.SKIPPED75 elif str_result == 'pending':76 return TestCaseStatuses.PENDING77 def send_logs_to_test_rail(self, run_id, item, outcome):78 test_case_ids = self.get_test_ids(item)79 if test_case_ids:80 for test_id in test_case_ids:81 try:82 actual_result = outcome.get_result()83 actual_outcome = actual_result.outcome84 if hasattr(item, 'execution_count'):85 if item.execution_count > 1 and actual_outcome == 'passed':86 actual_outcome = 'flaky'87 self.service.add_result_for_case(run_id=run_id, case_id=test_id,88 status=self.get_result_from_string(actual_outcome),89 comment=actual_result.capstderr)90 except APIError as e:91 Log.info(e)92 continue93 def filter_collected_tests_by_run_id(self, run_id, items):94 test_cases_ids = [test_case['case_id']95 for test_case in self.service.get_tests(run_id)]96 for test_case in items[:]:97 test_ids = self.get_test_ids(test_case)98 if test_ids:99 [items.remove(test_case) for test_id in self.get_test_ids(test_case)100 if test_id not in test_cases_ids]101 else:102 items.remove(test_case)103 def get_config_ids(self, configs: dict):104 out = list()105 config_groups = self.service.get_configs(self.project_id)106 for k, v in configs.items():107 for group in config_groups:108 if group['name'] == k:109 for config in group['configs']:110 if config['name'] == v:111 out.append(config['id'])112 break113 break...
icpc_2017_tests.py
Source:icpc_2017_tests.py
...17 if file.endswith(".ans"):18 with open(full_file_path, 'r') as ans_file:19 ans.append(ans_file.read().lstrip().rstrip())20 return [(i, a) for i, a in zip(ins, ans)]21def get_test_ids(folder):22 folder = os.path.join(TEST_DATA_FOLDER, folder)23 names = []24 for file in sorted(os.listdir(folder)):25 if file.endswith(".in"):26 names.append(os.path.basename(file))27 return names28@pytest.mark.parametrize("input_string,expected",29 get_test_data("B-clue"),30 ids=get_test_ids("B-clue"))31#@pytest.mark.timeout(1)32def test_b_clue(input_string, expected):33 assert b_clue(input_string) == expected34@pytest.mark.parametrize("input_string,expected",35 get_test_data("E-speed"),36 ids=get_test_ids("E-speed"))37@pytest.mark.timeout(1)38@pytest.mark.skip()39def test_e_speed(input_string, expected):40 assert math.isclose(e_speed(input_string),float(expected), rel_tol=10**-6, abs_tol=10**-6)41@pytest.mark.parametrize("input_string,expected",42 get_test_data("C-improbable"),43 ids=get_test_ids("C-improbable"))44@pytest.mark.timeout(1)45@pytest.mark.skip()46def test_c_improbable(input_string, expected):...
test_data_import.py
Source:test_data_import.py
1import pytest2from .base import load_test_suite_from_file, test_suite_items, get_test_ids, make_request, compare_response3@pytest.mark.parametrize('test_suite', load_test_suite_from_file('data_import.yml'), ids=get_test_ids)4def test_import(client, test_suite):5 for url, params in test_suite_items(test_suite):6 r = make_request(client, url, params)7 assert r.status_code == params['status_code']8 is_equal, error_message = compare_response(r.json, params['response'])...
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!!