How to use assertNotEqual method in autotest

Best Python code snippet using autotest_python

test_validation_error.py

Source:test_validation_error.py Github

copy

Full Screen

...29 "message",30 ]31 )32 self.assertEqual(error1, ValidationError("message"))33 self.assertNotEqual(error1, ValidationError("message2"))34 self.assertNotEqual(error1, error2)35 self.assertNotEqual(error1, error4)36 self.assertNotEqual(error1, error5)37 self.assertNotEqual(error1, error6)38 self.assertNotEqual(error1, error7)39 self.assertEqual(error1, mock.ANY)40 self.assertEqual(error2, ValidationError("message", code="my_code1"))41 self.assertNotEqual(error2, ValidationError("other", code="my_code1"))42 self.assertNotEqual(error2, error3)43 self.assertNotEqual(error2, error4)44 self.assertNotEqual(error2, error5)45 self.assertNotEqual(error2, error6)46 self.assertNotEqual(error2, error7)47 self.assertEqual(48 error4,49 ValidationError(50 "error %(parm1)s %(parm2)s",51 code="my_code1",52 params={"parm1": "val1", "parm2": "val2"},53 ),54 )55 self.assertNotEqual(56 error4,57 ValidationError(58 "error %(parm1)s %(parm2)s",59 code="my_code2",60 params={"parm1": "val1", "parm2": "val2"},61 ),62 )63 self.assertNotEqual(64 error4,65 ValidationError(66 "error %(parm1)s %(parm2)s",67 code="my_code1",68 params={"parm2": "val2"},69 ),70 )71 self.assertNotEqual(72 error4,73 ValidationError(74 "error %(parm1)s %(parm2)s",75 code="my_code1",76 params={"parm2": "val1", "parm1": "val2"},77 ),78 )79 self.assertNotEqual(80 error4,81 ValidationError(82 "error val1 val2",83 code="my_code1",84 ),85 )86 # params ordering is ignored.87 self.assertEqual(88 error4,89 ValidationError(90 "error %(parm1)s %(parm2)s",91 code="my_code1",92 params={"parm2": "val2", "parm1": "val1"},93 ),94 )95 self.assertEqual(96 error5,97 ValidationError({"field1": "message", "field2": "other"}),98 )99 self.assertNotEqual(100 error5,101 ValidationError({"field1": "message", "field2": "other2"}),102 )103 self.assertNotEqual(104 error5,105 ValidationError({"field1": "message", "field3": "other"}),106 )107 self.assertNotEqual(error5, error6)108 # fields ordering is ignored.109 self.assertEqual(110 error5,111 ValidationError({"field2": "other", "field1": "message"}),112 )113 self.assertNotEqual(error7, ValidationError(error7.error_list[1:]))114 self.assertNotEqual(115 ValidationError(["message"]),116 ValidationError([ValidationError("message", code="my_code")]),117 )118 # messages ordering is ignored.119 self.assertEqual(120 error7,121 ValidationError(list(reversed(error7.error_list))),122 )123 self.assertNotEqual(error4, ValidationError([error4]))124 self.assertNotEqual(ValidationError([error4]), error4)125 self.assertNotEqual(error4, ValidationError({"field1": error4}))126 self.assertNotEqual(ValidationError({"field1": error4}), error4)127 def test_eq_nested(self):128 error_dict = {129 "field1": ValidationError(130 "error %(parm1)s %(parm2)s",131 code="my_code",132 params={"parm1": "val1", "parm2": "val2"},133 ),134 "field2": "other",135 }136 error = ValidationError(error_dict)137 self.assertEqual(error, ValidationError(dict(error_dict)))138 self.assertEqual(139 error,140 ValidationError(141 {142 "field1": ValidationError(143 "error %(parm1)s %(parm2)s",144 code="my_code",145 params={"parm2": "val2", "parm1": "val1"},146 ),147 "field2": "other",148 }149 ),150 )151 self.assertNotEqual(152 error,153 ValidationError(154 {**error_dict, "field2": "message"},155 ),156 )157 self.assertNotEqual(158 error,159 ValidationError(160 {161 "field1": ValidationError(162 "error %(parm1)s val2",163 code="my_code",164 params={"parm1": "val1"},165 ),166 "field2": "other",167 }168 ),169 )170 def test_hash(self):171 error1 = ValidationError("message")172 error2 = ValidationError("message", code="my_code1")173 error3 = ValidationError("message", code="my_code2")174 error4 = ValidationError(175 "error %(parm1)s %(parm2)s",176 code="my_code1",177 params={"parm1": "val1", "parm2": "val2"},178 )179 error5 = ValidationError({"field1": "message", "field2": "other"})180 error6 = ValidationError({"field1": "message"})181 error7 = ValidationError(182 [183 ValidationError({"field1": "field error", "field2": "other"}),184 "message",185 ]186 )187 self.assertEqual(hash(error1), hash(ValidationError("message")))188 self.assertNotEqual(hash(error1), hash(ValidationError("message2")))189 self.assertNotEqual(hash(error1), hash(error2))190 self.assertNotEqual(hash(error1), hash(error4))191 self.assertNotEqual(hash(error1), hash(error5))192 self.assertNotEqual(hash(error1), hash(error6))193 self.assertNotEqual(hash(error1), hash(error7))194 self.assertEqual(195 hash(error2),196 hash(ValidationError("message", code="my_code1")),197 )198 self.assertNotEqual(199 hash(error2),200 hash(ValidationError("other", code="my_code1")),201 )202 self.assertNotEqual(hash(error2), hash(error3))203 self.assertNotEqual(hash(error2), hash(error4))204 self.assertNotEqual(hash(error2), hash(error5))205 self.assertNotEqual(hash(error2), hash(error6))206 self.assertNotEqual(hash(error2), hash(error7))207 self.assertEqual(208 hash(error4),209 hash(210 ValidationError(211 "error %(parm1)s %(parm2)s",212 code="my_code1",213 params={"parm1": "val1", "parm2": "val2"},214 )215 ),216 )217 self.assertNotEqual(218 hash(error4),219 hash(220 ValidationError(221 "error %(parm1)s %(parm2)s",222 code="my_code2",223 params={"parm1": "val1", "parm2": "val2"},224 )225 ),226 )227 self.assertNotEqual(228 hash(error4),229 hash(230 ValidationError(231 "error %(parm1)s %(parm2)s",232 code="my_code1",233 params={"parm2": "val2"},234 )235 ),236 )237 self.assertNotEqual(238 hash(error4),239 hash(240 ValidationError(241 "error %(parm1)s %(parm2)s",242 code="my_code1",243 params={"parm2": "val1", "parm1": "val2"},244 )245 ),246 )247 self.assertNotEqual(248 hash(error4),249 hash(250 ValidationError(251 "error val1 val2",252 code="my_code1",253 )254 ),255 )256 # params ordering is ignored.257 self.assertEqual(258 hash(error4),259 hash(260 ValidationError(261 "error %(parm1)s %(parm2)s",262 code="my_code1",263 params={"parm2": "val2", "parm1": "val1"},264 )265 ),266 )267 self.assertEqual(268 hash(error5),269 hash(ValidationError({"field1": "message", "field2": "other"})),270 )271 self.assertNotEqual(272 hash(error5),273 hash(ValidationError({"field1": "message", "field2": "other2"})),274 )275 self.assertNotEqual(276 hash(error5),277 hash(ValidationError({"field1": "message", "field3": "other"})),278 )279 self.assertNotEqual(error5, error6)280 # fields ordering is ignored.281 self.assertEqual(282 hash(error5),283 hash(ValidationError({"field2": "other", "field1": "message"})),284 )285 self.assertNotEqual(286 hash(error7),287 hash(ValidationError(error7.error_list[1:])),288 )289 self.assertNotEqual(290 hash(ValidationError(["message"])),291 hash(ValidationError([ValidationError("message", code="my_code")])),292 )293 # messages ordering is ignored.294 self.assertEqual(295 hash(error7),296 hash(ValidationError(list(reversed(error7.error_list)))),297 )298 self.assertNotEqual(hash(error4), hash(ValidationError([error4])))299 self.assertNotEqual(hash(ValidationError([error4])), hash(error4))300 self.assertNotEqual(301 hash(error4),302 hash(ValidationError({"field1": error4})),303 )304 def test_hash_nested(self):305 error_dict = {306 "field1": ValidationError(307 "error %(parm1)s %(parm2)s",308 code="my_code",309 params={"parm2": "val2", "parm1": "val1"},310 ),311 "field2": "other",312 }313 error = ValidationError(error_dict)314 self.assertEqual(hash(error), hash(ValidationError(dict(error_dict))))315 self.assertEqual(316 hash(error),317 hash(318 ValidationError(319 {320 "field1": ValidationError(321 "error %(parm1)s %(parm2)s",322 code="my_code",323 params={"parm1": "val1", "parm2": "val2"},324 ),325 "field2": "other",326 }327 )328 ),329 )330 self.assertNotEqual(331 hash(error),332 hash(333 ValidationError(334 {**error_dict, "field2": "message"},335 )336 ),337 )338 self.assertNotEqual(339 hash(error),340 hash(341 ValidationError(342 {343 "field1": ValidationError(344 "error %(parm1)s val2",345 code="my_code",346 params={"parm1": "val1"},347 ),348 "field2": "other",349 }350 )351 ),352 )

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