Best Python code snippet using gabbi_python
test_suitemaker.py
Source: test_suitemaker.py
...21 self.loader = unittest.defaultTestLoader22 def test_tests_key_required(self):23 test_yaml = {'name': 'house', 'url': '/'}24 with self.assertRaises(exception.GabbiFormatError) as failure:25 suitemaker.test_suite_from_dict(self.loader, 'foo', test_yaml, '.',26 'localhost', 80, None, None)27 self.assertEqual('malformed test file, "tests" key required',28 str(failure.exception))29 def test_upper_dict_required(self):30 test_yaml = [{'name': 'house', 'url': '/'}]31 with self.assertRaises(exception.GabbiFormatError) as failure:32 suitemaker.test_suite_from_dict(self.loader, 'foo', test_yaml, '.',33 'localhost', 80, None, None)34 self.assertEqual('malformed test file, invalid format',35 str(failure.exception))36 def test_inner_list_required(self):37 test_yaml = {'tests': {'name': 'house', 'url': '/'}}38 with self.assertRaises(exception.GabbiFormatError) as failure:39 suitemaker.test_suite_from_dict(self.loader, 'foo', test_yaml, '.',40 'localhost', 80, None, None)41 self.assertIn('test chunk is not a dict at',42 str(failure.exception))43 def test_name_key_required(self):44 test_yaml = {'tests': [{'url': '/'}]}45 with self.assertRaises(exception.GabbiFormatError) as failure:46 suitemaker.test_suite_from_dict(self.loader, 'foo', test_yaml, '.',47 'localhost', 80, None, None)48 self.assertEqual('Test name missing in a test in foo.',49 str(failure.exception))50 def test_url_key_required(self):51 test_yaml = {'tests': [{'name': 'missing url'}]}52 with self.assertRaises(exception.GabbiFormatError) as failure:53 suitemaker.test_suite_from_dict(self.loader, 'foo', test_yaml, '.',54 'localhost', 80, None, None)55 self.assertEqual('Test url missing in test foo_missing_url.',56 str(failure.exception))57 def test_unsupported_key_errors(self):58 test_yaml = {'tests': [{59 'url': '/',60 'name': 'simple',61 'bad_key': 'wow',62 }]}63 with self.assertRaises(exception.GabbiFormatError) as failure:64 suitemaker.test_suite_from_dict(self.loader, 'foo', test_yaml, '.',65 'localhost', 80, None, None)66 self.assertIn("Invalid test keys used in test foo_simple:",67 str(failure.exception))68 def test_method_url_pair_format_error(self):69 test_yaml = {'defaults': {'GET': '/foo'}, 'tests': []}70 with self.assertRaises(exception.GabbiFormatError) as failure:71 suitemaker.test_suite_from_dict(self.loader, 'foo', test_yaml, '.',72 'localhost', 80, None, None)73 self.assertIn('"METHOD: url" pairs not allowed in defaults',74 str(failure.exception))75 def test_method_url_pair_duplication_format_error(self):76 test_yaml = {'tests': [{77 'GET': '/',78 'POST': '/',79 'name': 'duplicate methods',80 }]}81 with self.assertRaises(exception.GabbiFormatError) as failure:82 suitemaker.test_suite_from_dict(self.loader, 'foo', test_yaml, '.',83 'localhost', 80, None, None)84 self.assertIn(85 'duplicate method/URL directive in "foo_duplicate_methods"',86 str(failure.exception)87 )88 def test_dict_on_invalid_key(self):89 test_yaml = {'tests': [{90 'name': '...',91 'GET': '/',92 'response_html': {93 'foo': 'hello',94 'bar': 'world',95 }96 }]}97 with self.assertRaises(exception.GabbiFormatError) as failure:98 suitemaker.test_suite_from_dict(self.loader, 'foo', test_yaml, '.',99 'localhost', 80, None, None)100 self.assertIn(101 "invalid key in test: 'response_html'",102 str(failure.exception)103 )104 def test_response_handlers_same_test_key_yaml_last(self):105 test_yaml = {'tests': [{106 'name': '...',107 'GET': '/',108 'response_json_paths': {109 'foo': 'hello',110 'bar': 'world',111 }112 }]}113 handler_objects = []114 ydlj_handler_object = ydlj_handler.YAMLDiskLoadingJSONHandler()115 for handler in handlers.RESPONSE_HANDLERS:116 handler_objects.append(handler())117 handler_objects.append(ydlj_handler_object)118 file_suite = suitemaker.test_suite_from_dict(119 self.loader, 'foo', test_yaml, '.', 'localhost', 80, None, None,120 handlers=handler_objects)121 response_handlers = file_suite._tests[0].response_handlers122 self.assertNotIn(ydlj_handler_object, response_handlers)123 def test_response_handlers_same_test_key_yaml_first(self):124 test_yaml = {'tests': [{125 'name': '...',126 'GET': '/',127 'response_json_paths': {128 'foo': 'hello',129 'bar': 'world',130 }131 }]}132 ydlj_handler_object = ydlj_handler.YAMLDiskLoadingJSONHandler()133 handler_objects = [ydlj_handler_object]134 for handler in handlers.RESPONSE_HANDLERS:135 handler_objects.append(handler())136 file_suite = suitemaker.test_suite_from_dict(137 self.loader, 'foo', test_yaml, '.', 'localhost', 80, None, None,138 handlers=handler_objects)139 response_handlers = file_suite._tests[0].response_handlers...
test_driver.py
Source: test_driver.py
...47 driver.build_tests(self.test_dir, self.loader)48 def test_tests_key_required(self):49 test_yaml = {'name': 'house', 'url': '/'}50 with self.assertRaises(driver.GabbiFormatError) as failure:51 driver.test_suite_from_dict(self.loader, 'foo', test_yaml, '.',52 'localhost', 80, None, None)53 self.assertEqual('malformed test file, "tests" key required',54 str(failure.exception))55 def test_upper_dict_required(self):56 test_yaml = [{'name': 'house', 'url': '/'}]57 with self.assertRaises(driver.GabbiFormatError) as failure:58 driver.test_suite_from_dict(self.loader, 'foo', test_yaml, '.',59 'localhost', 80, None, None)60 self.assertEqual('malformed test file, invalid format',61 str(failure.exception))62 def test_inner_list_required(self):63 test_yaml = {'tests': {'name': 'house', 'url': '/'}}64 with self.assertRaises(driver.GabbiFormatError) as failure:65 driver.test_suite_from_dict(self.loader, 'foo', test_yaml, '.',66 'localhost', 80, None, None)67 self.assertIn('test chunk is not a dict at',68 str(failure.exception))69 def test_name_key_required(self):70 test_yaml = {'tests': [{'url': '/'}]}71 with self.assertRaises(driver.GabbiFormatError) as failure:72 driver.test_suite_from_dict(self.loader, 'foo', test_yaml, '.',73 'localhost', 80, None, None)74 self.assertEqual('Test name missing in a test in foo.',75 str(failure.exception))76 def test_url_key_required(self):77 test_yaml = {'tests': [{'name': 'missing url'}]}78 with self.assertRaises(driver.GabbiFormatError) as failure:79 driver.test_suite_from_dict(self.loader, 'foo', test_yaml, '.',80 'localhost', 80, None, None)81 self.assertEqual('Test url missing in test foo_missing_url.',82 str(failure.exception))83 def test_unsupported_key_errors(self):84 test_yaml = {'tests': [{85 'url': '/',86 'name': 'simple',87 'bad_key': 'wow',88 }]}89 with self.assertRaises(driver.GabbiFormatError) as failure:90 driver.test_suite_from_dict(self.loader, 'foo', test_yaml, '.',91 'localhost', 80, None, None)92 self.assertIn("Invalid test keys used in test foo_simple:",93 str(failure.exception))94 def test_method_url_pair_format_error(self):95 test_yaml = {'defaults': {'GET': '/foo'}, 'tests': []}96 with self.assertRaises(driver.GabbiFormatError) as failure:97 driver.test_suite_from_dict(self.loader, 'foo', test_yaml, '.',98 'localhost', 80, None, None)99 self.assertIn('"METHOD: url" pairs not allowed in defaults',100 str(failure.exception))101 def test_method_url_pair_duplication_format_error(self):102 test_yaml = {'tests': [{103 'GET': '/',104 'POST': '/',105 'name': 'duplicate methods',106 }]}107 with self.assertRaises(driver.GabbiFormatError) as failure:108 driver.test_suite_from_dict(self.loader, 'foo', test_yaml, '.',109 'localhost', 80, None, None)110 self.assertIn(111 'duplicate method/URL directive in "foo_duplicate_methods"',112 str(failure.exception)113 )114 def test_dict_on_invalid_key(self):115 test_yaml = {'tests': [{116 'name': '...',117 'GET': '/',118 'response_html': {119 'foo': 'hello',120 'bar': 'world',121 }122 }]}123 with self.assertRaises(driver.GabbiFormatError) as failure:124 driver.test_suite_from_dict(self.loader, 'foo', test_yaml, '.',125 'localhost', 80, None, None)126 self.assertIn(127 "invalid key in test: 'response_html'",128 str(failure.exception)...
testcase.py
Source: testcase.py
...15 # Take only the host name and port from the live server:16 _, authority = self.live_server_url.split('://')17 host, port = authority.split(':')18 # Use Gabbi to create the test suite from our declaration:19 suite = test_suite_from_dict(20 loader=defaultTestLoader,21 test_base_name=self.id(),22 suite_dict=gabbi_declaration,23 test_directory='.',24 host=host,25 port=port,26 fixture_module=None,27 intercept=None,28 handlers=[29 handler()30 for handler in RESPONSE_HANDLERS31 ],32 )33 # Run the test. We store the the output into a custom stream so that...
Check out the latest blogs from LambdaTest on this topic:
Pair testing can help you complete your testing tasks faster and with higher quality. But who can do pair testing, and when should it be done? And what form of pair testing is best for your circumstance? Check out this blog for more information on how to conduct pair testing to optimize its benefits.
There are times when developers get stuck with a problem that has to do with version changes. Trying to run the code or test without upgrading the package can result in unexpected errors.
Continuous integration is a coding philosophy and set of practices that encourage development teams to make small code changes and check them into a version control repository regularly. Most modern applications necessitate the development of code across multiple platforms and tools, so teams require a consistent mechanism for integrating and validating changes. Continuous integration creates an automated way for developers to build, package, and test their applications. A consistent integration process encourages developers to commit code changes more frequently, resulting in improved collaboration and code quality.
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!!