How to use test_wrong_parser method in avocado

Best Python code snippet using avocado_python

test_duids.py

Source:test_duids.py Github

copy

Full Screen

...30class LinkLayerTimeDUIDTestCase(UnknownDUIDTestCase):31 def setUp(self):32 self.duid_object = LinkLayerTimeDUID(hardware_type=1, time=15, link_layer_address=bytes.fromhex('3431c43cb2f1'))33 self.duid_bytes = bytes.fromhex('000100010000000f3431c43cb2f1')34 def test_wrong_parser(self):35 with self.assertRaisesRegex(ValueError, 'does not contain LinkLayerDUID'):36 duid = LinkLayerDUID()37 duid.load_from(self.duid_bytes, length=len(self.duid_bytes))38 def test_validate_hardware_type(self):39 good_duid_object = LinkLayerTimeDUID(0, 0, b'demo')40 good_duid_object.validate()41 bad_duid_object = LinkLayerTimeDUID(-1, 0, b'demo')42 with self.assertRaisesRegex(ValueError, 'unsigned 16 bit integer'):43 bad_duid_object.validate()44 bad_duid_object = LinkLayerTimeDUID(2 ** 16, 0, b'demo')45 with self.assertRaisesRegex(ValueError, 'unsigned 16 bit integer'):46 bad_duid_object.validate()47 def test_validate_time(self):48 good_duid_object = LinkLayerTimeDUID(0, 0, b'demo')49 good_duid_object.validate()50 bad_duid_object = LinkLayerTimeDUID(0, -1, b'demo')51 with self.assertRaisesRegex(ValueError, 'unsigned 32 bit integer'):52 bad_duid_object.validate()53 bad_duid_object = LinkLayerTimeDUID(0, 2 ** 32, b'demo')54 with self.assertRaisesRegex(ValueError, 'unsigned 32 bit integer'):55 bad_duid_object.validate()56 def test_validate_link_layer(self):57 # noinspection PyTypeChecker58 bad_duid_object = LinkLayerTimeDUID(0, 0, 'demo')59 with self.assertRaisesRegex(ValueError, 'sequence of bytes'):60 bad_duid_object.validate()61 def test_validate_length(self):62 good_duid_object = LinkLayerTimeDUID(0, 0, 120 * b'x')63 good_duid_object.validate()64 bad_duid_object = LinkLayerTimeDUID(0, 0, 121 * b'x')65 with self.assertRaisesRegex(ValueError, 'cannot be longer than 120 bytes'):66 bad_duid_object.validate()67 def test_display_ethernet(self):68 output = str(self.duid_object)69 self.assertEqual(output, "LinkLayerTimeDUID(\n"70 " hardware_type=Ethernet (1),\n"71 " time=15,\n"72 " link_layer_address=34:31:c4:3c:b2:f1,\n"73 ")")74 def test_display_other(self):75 self.duid_object.hardware_type = 276 output = str(self.duid_object)77 self.assertEqual(output, "LinkLayerTimeDUID(\n"78 " hardware_type=Experimental Ethernet (2),\n"79 " time=15,\n"80 " link_layer_address=b'41\\xc4<\\xb2\\xf1',\n"81 ")")82class EnterpriseDUIDTestCase(UnknownDUIDTestCase):83 def setUp(self):84 self.duid_object = EnterpriseDUID(enterprise_number=40208, identifier=b'DHCPKitUnitTestIdentifier')85 self.duid_bytes = bytes.fromhex('000200009d10444843504b6974556e6974546573744964656e746966696572')86 def test_wrong_parser(self):87 with self.assertRaisesRegex(ValueError, 'does not contain LinkLayerTimeDUID'):88 duid = LinkLayerTimeDUID()89 duid.load_from(self.duid_bytes, length=len(self.duid_bytes))90 def test_validate_enterprise_number(self):91 good_duid_object = EnterpriseDUID(0, b'demo')92 good_duid_object.validate()93 bad_duid_object = EnterpriseDUID(-1, b'demo')94 with self.assertRaisesRegex(ValueError, 'unsigned 32 bit integer'):95 bad_duid_object.validate()96 bad_duid_object = EnterpriseDUID(2 ** 32, b'demo')97 with self.assertRaisesRegex(ValueError, 'unsigned 32 bit integer'):98 bad_duid_object.validate()99 def test_validate_identifier(self):100 # noinspection PyTypeChecker101 bad_duid_object = EnterpriseDUID(0, 'demo')102 with self.assertRaisesRegex(ValueError, 'sequence of bytes'):103 bad_duid_object.validate()104 def test_validate_length(self):105 good_duid_object = EnterpriseDUID(0, 122 * b'x')106 good_duid_object.validate()107 bad_duid_object = EnterpriseDUID(0, 123 * b'x')108 with self.assertRaisesRegex(ValueError, 'cannot be longer than 122 bytes'):109 bad_duid_object.validate()110class LinkLayerDUIDTestCase(UnknownDUIDTestCase):111 def setUp(self):112 self.duid_object = LinkLayerDUID(hardware_type=1, link_layer_address=bytes.fromhex('3431c43cb2f1'))113 self.duid_bytes = bytes.fromhex('000300013431c43cb2f1')114 def test_wrong_parser(self):115 with self.assertRaisesRegex(ValueError, 'does not contain EnterpriseDUID'):116 duid = EnterpriseDUID()117 duid.load_from(self.duid_bytes, length=len(self.duid_bytes))118 def test_validate_hardware_type(self):119 good_duid_object = LinkLayerDUID(0, b'demo')120 good_duid_object.validate()121 bad_duid_object = LinkLayerDUID(-1, b'demo')122 with self.assertRaisesRegex(ValueError, 'unsigned 16 bit integer'):123 bad_duid_object.validate()124 bad_duid_object = LinkLayerDUID(2 ** 16, b'demo')125 with self.assertRaisesRegex(ValueError, 'unsigned 16 bit integer'):126 bad_duid_object.validate()127 def test_validate_link_layer(self):128 # noinspection PyTypeChecker...

Full Screen

Full Screen

test_hintfiles.py

Source:test_hintfiles.py Github

copy

Full Screen

...22 self.good_file.write(GOOD)23 self.good_file.close()24 self.wrong_hint = HintParser(self.wrong_file.name)25 self.good_hint = HintParser(self.good_file.name)26 def test_wrong_parser(self):27 with self.assertRaises(SettingsError) as context:28 self.wrong_hint.validate_kind_section('tap')29 self.assertTrue('Section tap is not defined' in str(context.exception))30 @skipUnlessPathExists('/bin/true')31 def test_types(self):32 res = self.good_hint.get_resolutions()33 self.assertEqual(len(res), 1)34 self.assertIsInstance(res[0], ReferenceResolution)35 resolutions = res[0].resolutions36 self.assertEqual(len(resolutions), 1)37 self.assertIsInstance(resolutions[0], Runnable)38 @skipUnlessPathExists('/bin/true')39 def test_reference_names(self):40 res = self.good_hint.get_resolutions()[0]...

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