How to use test_invalid_input method in SeleniumBase

Best Python code snippet using SeleniumBase

test_invalid_input.py

Source:test_invalid_input.py Github

copy

Full Screen

...54 '\' rather than expected type \'' + return_type.__name__) + '\'.')55 return False, None56 57 return True, results58def test_invalid_input(test_function, function_name, reason_invalid):59 integrationtestlib.log(('Verifying that the \'' + function_name +60 '\' function fails against invalid input.'))61 62 try:63 test_function()64 except:65 # An error occurred, so the invalid input was detected.66 return True67 68 # We didn't want success here!69 log_error(function_name, 'Function succeded with invalid input: ' + reason_invalid)70 return False71def test_api_version():72 test_function = lambda: XMLRPC_PROXY.api_version()73 test_valid_input(test_function, str, 'api_version')74 75 # Any argument should cause problems...76 test_function = lambda: XMLRPC_PROXY.api_version('')77 test_invalid_input(test_function, 'api_version', 'extra argument')78def test_build_installers():79 vessels = [{'percentage': 80, 'owner': 'owner'}]80 test_function = lambda: XMLRPC_PROXY.build_installers(vessels)81 success, results = test_valid_input(test_function, dict, 'build_installers')82 83 # A user might not have their vessels add to 80%.84 vessels = [{'percentage': 100, 'owner': 'owner'}]85 test_function = lambda: XMLRPC_PROXY.build_installers(vessels)86 test_invalid_input(test_function, 'build_installers', 'vessels add to 100%')87 88 # A user might neglect to give all vessels an owner.89 vessels = [{'percentage': 80}]90 test_function = lambda: XMLRPC_PROXY.build_installers(vessels)91 test_invalid_input(test_function, 'build_installers', 'vessel lacks owner')92 93 # A user might give an invalid cryptographic key.94 vessels = [{'percentage': 80, 'owner': 'owner'}]95 user_data = {'owner': {'public_key': 'INVALID'}}96 test_function = lambda: XMLRPC_PROXY.build_installers(vessels, user_data)97 test_invalid_input(test_function, 'build_installers', 'invalid cryptographic key')98 99 return success, results100def test_get_urls(build_id):101 test_function = lambda: XMLRPC_PROXY.get_urls(build_id)102 test_valid_input(test_function, dict, 'get_urls')103 104 # A user might give an invalid build ID.105 test_function = lambda: XMLRPC_PROXY.get_urls('INVALID')106 test_invalid_input(test_function, 'get_urls', 'invalid build ID')107 108 # A user might give a build ID that (probably) does not exist.109 test_function = lambda: XMLRPC_PROXY.get_urls('0123456789012345678901234567890123456789')110 test_invalid_input(test_function, 'get_urls', 'non-existent build ID')111def report_results():112 # If there are no entries in the dictionary, then no errors occurred.113 if len(ERRORS) == 0:114 integrationtestlib.log('All tests successful!')115 return116 117 # Otherwise, errors occurred...118 error_string = 'The following errors occurred:\n'119 120 for function in ERRORS: 121 for error in ERRORS[function]:122 error_string += '\n[' + function + '] ' + error123 integrationtestlib.log(error_string)124 integrationtestlib.notify(error_string, 'Custom Installer Builder test failure')...

Full Screen

Full Screen

test_resize.py

Source:test_resize.py Github

copy

Full Screen

...81 ds.config.set_num_parallel_workers(original_num_parallel_workers)82 test_resize_md5_parameters("Test single int for size", 5, "resize_01_result.npz", 5, plot)83 test_resize_md5_parameters("Test tuple for size", (5, 7), "resize_02_result.npz", 7, plot)84def test_resize_op_invalid_input():85 def test_invalid_input(test_name, size, interpolation, error, error_msg):86 logger.info("Test Resize with bad input: {0}".format(test_name))87 with pytest.raises(error) as error_info:88 vision.Resize(size, interpolation)89 assert error_msg in str(error_info.value)90 test_invalid_input("invalid size parameter type as a single number", 4.5, Inter.LINEAR, TypeError,91 "Size should be a single integer or a list/tuple (h, w) of length 2.")92 test_invalid_input("invalid size parameter shape", (2, 3, 4), Inter.LINEAR, TypeError,93 "Size should be a single integer or a list/tuple (h, w) of length 2.")94 test_invalid_input("invalid size parameter type in a tuple", (2.3, 3), Inter.LINEAR, TypeError,95 "incompatible constructor arguments.")96 test_invalid_input("invalid Interpolation value", (2.3, 3), None, KeyError, "None")97if __name__ == "__main__":98 test_resize_op(plot=True)99 test_resize_md5(plot=True)...

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 SeleniumBase 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