Best Python code snippet using avocado_python
test_exceptions.py
Source:test_exceptions.py
...60 e = AlreadyExistsError(entity='UniqueIdentity', eid='FFFFFFFFFFF')61 self.assertEqual(str(e), "UniqueIdentity 'FFFFFFFFFFF' already exists in the registry")62 self.assertEqual(e.entity, 'UniqueIdentity')63 self.assertEqual(e.eid, 'FFFFFFFFFFF')64 def test_no_args(self):65 """Check whether it raises a KeyError exception when66 required parameters are not given"""67 kwargs = {}68 self.assertRaises(KeyError, AlreadyExistsError, **kwargs)69class TestBadFileFormatError(unittest.TestCase):70 def test_message(self):71 """Make sure that prints the correct error"""72 e = BadFileFormatError(cause='Invalid file format')73 self.assertEqual("Invalid file format", str(e))74 def test_no_args(self):75 """Check whether it raises a KeyError exception when76 required parameters are not given"""77 kwargs = {}78 self.assertRaises(KeyError, BadFileFormatError, **kwargs)79class TestDatabaseError(unittest.TestCase):80 def test_message(self):81 """Make sure that prints the correct error"""82 e = DatabaseError(error="Unknown database 'mydb'", code=1049)83 self.assertEqual("Unknown database 'mydb' (err: 1049)", str(e))84 def test_no_args(self):85 """Check whether it raises a KeyError exception when86 required parameters are not given"""87 kwargs = {}88 self.assertRaises(KeyError, DatabaseError, **kwargs)89 kwargs = {'error': "Unknown database 'mydb'"}90 self.assertRaises(KeyError, DatabaseError, **kwargs)91 kwargs = {'code': 1049}92 self.assertRaises(KeyError, DatabaseError, **kwargs)93class TestDatabaseExists(unittest.TestCase):94 def test_message(self):95 """Make sure that prints the correct error"""96 e = DatabaseExists(error="Database exists 'mydb'", code=1049)97 self.assertEqual("Database exists 'mydb' (err: 1049)", str(e))98 def test_no_args(self):99 """Check whether it raises a KeyError exception when100 required parameters are not given"""101 kwargs = {}102 self.assertRaises(KeyError, DatabaseExists, **kwargs)103 kwargs = {'error': "Database existis 'mydb'"}104 self.assertRaises(KeyError, DatabaseExists, **kwargs)105 kwargs = {'code': 1049}106 self.assertRaises(KeyError, DatabaseExists, **kwargs)107class TestInvalidDateError(unittest.TestCase):108 def test_message(self):109 """Make sure that prints the correct error"""110 e = InvalidDateError(date='1900-13-01')111 self.assertEqual("1900-13-01 is not a valid date",112 str(e))113 def test_no_args(self):114 """Check whether it raises a KeyError exception when115 required parameters are not given"""116 kwargs = {}117 self.assertRaises(KeyError, InvalidDateError, **kwargs)118class TestInvalidFormatError(unittest.TestCase):119 def test_message(self):120 """Make sure that prints the correct error"""121 e = InvalidFormatError(cause='error on line 10')122 self.assertEqual("error on line 10", str(e))123 def test_no_args(self):124 """Check whether it raises a KeyError exception when125 required parameters are not given"""126 kwargs = {}127 self.assertRaises(KeyError, InvalidFormatError, **kwargs)128class TestLoadError(unittest.TestCase):129 def test_message(self):130 """Make sure that prints the correct error"""131 e = LoadError(cause='Invalid json format')132 self.assertEqual("Invalid json format", str(e))133 def test_no_args(self):134 """Check whether it raises a KeyError exception when135 required parameters are not given"""136 kwargs = {}137 self.assertRaises(KeyError, LoadError, **kwargs)138class TestMatcherNotSupported(unittest.TestCase):139 def test_message(self):140 """Make sure that prints the correct error"""141 e = MatcherNotSupportedError(matcher='custom')142 self.assertEqual("custom identity matcher is not supported",143 str(e))144 def test_no_args(self):145 """Check whether it raises a KeyError exception when146 required parameters are not given"""147 kwargs = {}148 self.assertRaises(KeyError, InvalidDateError, **kwargs)149class TestNotFoundError(unittest.TestCase):150 def test_message(self):151 """Make sure that prints the correct error"""152 e = NotFoundError(entity='example.com')153 self.assertEqual("example.com not found in the registry",154 str(e))155 def test_no_args(self):156 """Check whether it raises a KeyError exception when157 required parameters are not given"""158 kwargs = {}159 self.assertRaises(KeyError, NotFoundError, **kwargs)160if __name__ == "__main__":...
test_easy_commands.py
Source:test_easy_commands.py
...31 except PSkip:32 return True33class CommandClearTestCase(BotInitializer):34 Command = Clear35 def test_no_args(self):36 return self.check_correct_answer()37class CommandDocumentationTestCase(BotInitializer):38 Command = Documentation39 def test_no_args(self):40 return self.check_correct_answer()41class CommandDonateTestCase(BotInitializer):42 Command = Donate43 def test_no_args(self):44 return self.check_correct_answer()45class CommandGayAnswerTestCase(BotInitializer):46 Command = GayAnswer47 def test_no_args(self):48 return self.check_correct_answer()49class CommandGitTestCase(BotInitializer):50 Command = Git51 def test_no_args(self):52 return self.check_correct_answer()53class CommandGoogleTestCase(BotInitializer):54 Command = Google55 def test_no_args(self):56 self.check_correct_pwarning()57 def test_google_link(self):58 self.event.set_message("гÑгл пÑивеÑ")59 self.check_correct_answer()60class CommandHiTestCase(BotInitializer):61 Command = Hi62 def test_no_args_pm(self):63 self.event.is_from_pm = True64 return self.check_correct_answer()65 def test_no_args_chat(self):66 self.event.is_from_chat = True67 try:68 return self.check_correct_answer()69 except PSkip:70 return True71class CommandIssuesTestCase(BotInitializer):72 Command = Issues73 def test_no_args(self):74 return self.check_correct_answer()75class CommandNoTestCase(BotInitializer):76 Command = No77 def test_no_args(self):78 return self.check_correct_answer()79class CommandNyaTestCase(BotInitializer):80 Command = Nya81 def test_no_args(self):82 return self.check_correct_answer()83class CommandPingTestCase(BotInitializer):84 Command = Ping85 def test_no_args(self):86 return self.check_correct_answer()87class CommandRoflTestCase(BotInitializer):88 Command = Rofl89 def test_no_args(self):90 return self.check_correct_answer()91class CommandShitTestCase(BotInitializer):92 Command = Shit93 def test_no_args(self):94 return self.check_correct_answer()95class CommandShoTestCase(BotInitializer):96 Command = Sho97 def test_no_args(self):98 return self.check_correct_answer()99class CommandSorryMeTestCase(BotInitializer):100 Command = SorryMe101 def test_no_args(self):102 return self.check_correct_answer()103class CommandStartLadaTestCase(BotInitializer):104 Command = StartLada105 def test_no_args(self):106 return self.check_correct_answer()107class CommandThanksTestCase(BotInitializer):108 Command = Thanks109 def test_no_args(self):110 return self.check_correct_answer()111class CommandYesTestCase(BotInitializer):112 Command = Yes113 def test_no_args(self):...
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!!