How to use test_bad method in pytest-benchmark

Best Python code snippet using pytest-benchmark

test_decorators.py

Source:test_decorators.py Github

copy

Full Screen

...25 @runtime_validation26 class SampleClass:27 def test(self, data: int) -> int:28 return data29 def test_bad(self, data: typing.Any) -> int:30 return data31 sample = SampleClass()32 self.assertEqual(sample.test(1), 1)33 self.assertEqual(sample.test_bad(1), 1)34 with self.assertRaises(RuntimeTypeError):35 sample.test('')36 with self.assertRaises(RuntimeTypeError):37 sample.test_bad('')38 def test_method(self):39 """40 Checks if a method of a class object can be decorated41 """42 class SampleClass:43 @runtime_validation44 def test(self, data: int) -> int:45 return data46 @runtime_validation47 def test_bad(self, data: typing.Any) -> int:48 return data49 sample = SampleClass()50 self.assertEqual(sample.test(1), 1)51 self.assertEqual(sample.test_bad(1), 1)52 with self.assertRaises(RuntimeTypeError):53 sample.test('')54 with self.assertRaises(RuntimeTypeError):55 sample.test_bad('')56 def test_staticmethod(self):57 """58 Checks if a staticmethod of a class object can be decorated59 """60 class SampleClass:61 @runtime_validation62 @staticmethod63 def test(data: int) -> int:64 return data65 @staticmethod66 @runtime_validation67 def test2(data: int) -> int:68 return data69 @runtime_validation70 @staticmethod71 def test_bad(data: typing.Any) -> int:72 return data73 @staticmethod74 @runtime_validation75 def test_bad2(data: typing.Any) -> int:76 return data77 sample = SampleClass()78 self.assertEqual(sample.test(1), 1)79 self.assertEqual(sample.test2(1), 1)80 self.assertEqual(sample.test_bad(1), 1)81 self.assertEqual(sample.test_bad2(1), 1)82 self.assertEqual(SampleClass.test(1), 1)83 self.assertEqual(SampleClass.test2(1), 1)84 self.assertEqual(SampleClass.test_bad(1), 1)85 self.assertEqual(SampleClass.test_bad2(1), 1)86 with self.assertRaises(RuntimeTypeError):87 sample.test('')88 with self.assertRaises(RuntimeTypeError):89 sample.test2('')90 with self.assertRaises(RuntimeTypeError):91 sample.test_bad('')92 with self.assertRaises(RuntimeTypeError):93 sample.test_bad2('')94 with self.assertRaises(RuntimeTypeError):95 SampleClass.test('')96 with self.assertRaises(RuntimeTypeError):97 SampleClass.test2('')98 with self.assertRaises(RuntimeTypeError):99 SampleClass.test_bad('')100 with self.assertRaises(RuntimeTypeError):101 SampleClass.test_bad2('')102 def test_classmethod(self):103 """104 Checks if a classmethod of a class object can be decorated105 """106 class SampleClass:107 @runtime_validation108 @classmethod109 def test(cls, data: int) -> int:110 return data111 @classmethod112 @runtime_validation113 def test2(cls, data: int) -> int:114 return data115 @runtime_validation116 @classmethod117 def test_bad(cls, data: typing.Any) -> int:118 return data119 @classmethod120 @runtime_validation121 def test_bad2(cls, data: typing.Any) -> int:122 return data123 sample = SampleClass()124 self.assertEqual(sample.test(1), 1)125 self.assertEqual(sample.test2(1), 1)126 self.assertEqual(sample.test_bad(1), 1)127 self.assertEqual(sample.test_bad2(1), 1)128 self.assertEqual(SampleClass.test(1), 1)129 self.assertEqual(SampleClass.test2(1), 1)130 self.assertEqual(SampleClass.test_bad(1), 1)131 self.assertEqual(SampleClass.test_bad2(1), 1)132 #with self.assertRaises(RuntimeTypeError):133 # sample.test('')134 with self.assertRaises(RuntimeTypeError):135 sample.test2('')136 #with self.assertRaises(RuntimeTypeError):137 # sample.test_bad('')138 with self.assertRaises(RuntimeTypeError):139 sample.test_bad2('')140 #with self.assertRaises(RuntimeTypeError):141 # SampleClass.test('')142 with self.assertRaises(RuntimeTypeError):143 SampleClass.test2('')144 #with self.assertRaises(RuntimeTypeError):145 # SampleClass.test_bad('')146 with self.assertRaises(RuntimeTypeError):147 SampleClass.test_bad2('')148 def test_property(self):149 """150 Checks if property object can be type checked151 """152 @runtime_validation153 class Sample:154 def __init__(self):155 self._x = 0156 @property157 def x(self):158 return self._x159 @x.setter...

Full Screen

Full Screen

maker_admin_test.py

Source:maker_admin_test.py Github

copy

Full Screen

...31 self.assertEqual("Larsson", m.lastname)32 self.assertEqual("123213433334", m.rfid_tag)33 self.assertEqual(None, m.end_timestamp)34 def test_parse_bad_member(self):35 def test_bad(**kwargs):36 obj = deepcopy(valid_member)37 obj.update(kwargs)38 with self.assertRaises(ValueError):39 MakerAdminClient.response_data_to_members([obj])40 41 test_bad(member_id="bad id")42 test_bad(member_number="not a number")43 test_bad(firstname=123)44 test_bad(lastname=3334)45 test_bad(end_date="XYZ")46 def test_bad_key(**kwargs):47 obj = deepcopy(valid_member)48 obj['keys'][0].update(kwargs)49 with self.assertRaises(ValueError):50 MakerAdminClient.response_data_to_members([obj])51 test_bad_key(key_id=False)52 test_bad_key(rfid_tag=244)53 def test_no_keys_is_filtered(self):54 obj = deepcopy(valid_member)55 obj['keys'] = []56 self.assertEqual([], MakerAdminClient.response_data_to_members([obj]))57 def test_unblocked_key_with_latest_end_timestamp_is_picked(self):58 m, = MakerAdminClient.response_data_to_members([59 dict(...

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 pytest-benchmark 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