Skip to content

Instantly share code, notes, and snippets.

View ainani's full-sized avatar

Abhishek Inani ainani

  • Bangalore
View GitHub Profile
@ainani
ainani / dynamic_way.py
Created July 7, 2020 08:53
calling test functions dynamic way
def map_test_cases_dynamic_way(test_case: str = None):
"""Method to map the test cases target functions based on test_case id received"""
print("The dynamic way calling...")
test_cases = {f'Test_{i:03}': f'test_function_{i:03}' for i in range(100)}
for tc, func in test_cases.items():
if tc.find(test_case) >= 0:
print(f"Mapped test case found for tc: {tc} as : {func}")
status = eval(func)()
return status
else:
@ainani
ainani / if_else_to_dict.py
Last active July 7, 2020 08:51
multiple if-else to dict
def map_test_cases_dict_way(test_case: str = None):
"""Method to map the test cases target functions based on test_case id received"""
print("The dictionary way calling...")
test_cases = {
'Test_001': test_function_001,
'Test_002': test_function_002,
'Test_003': test_function_003,
'Test_004': test_function_004,
'Test_005': test_function_005,
'Test_006': test_function_006,
@ainani
ainani / multiple_if_elif.py
Last active July 7, 2020 08:52
An alternative to multiple if..elif..elif in Python
def map_test_cases_traditional_way(test_case: str):
print("The traditional calling...")
# Traditional if..elif..elif in Python
if test_case == 'Test_001':
test_function_001()
elif test_case == 'Test_002':
test_function_002()
elif test_case == 'Test_003':
test_function_003()
elif test_case == 'Test_004':