(self)
| 179 | ) |
| 180 | |
| 181 | def test_hash(self): |
| 182 | error1 = ValidationError("message") |
| 183 | error2 = ValidationError("message", code="my_code1") |
| 184 | error3 = ValidationError("message", code="my_code2") |
| 185 | error4 = ValidationError( |
| 186 | "error %(parm1)s %(parm2)s", |
| 187 | code="my_code1", |
| 188 | params={"parm1": "val1", "parm2": "val2"}, |
| 189 | ) |
| 190 | error5 = ValidationError({"field1": "message", "field2": "other"}) |
| 191 | error6 = ValidationError({"field1": "message"}) |
| 192 | error7 = ValidationError( |
| 193 | [ |
| 194 | ValidationError({"field1": "field error", "field2": "other"}), |
| 195 | "message", |
| 196 | ] |
| 197 | ) |
| 198 | |
| 199 | self.assertEqual(hash(error1), hash(ValidationError("message"))) |
| 200 | self.assertNotEqual(hash(error1), hash(ValidationError("message2"))) |
| 201 | self.assertNotEqual(hash(error1), hash(error2)) |
| 202 | self.assertNotEqual(hash(error1), hash(error4)) |
| 203 | self.assertNotEqual(hash(error1), hash(error5)) |
| 204 | self.assertNotEqual(hash(error1), hash(error6)) |
| 205 | self.assertNotEqual(hash(error1), hash(error7)) |
| 206 | self.assertEqual( |
| 207 | hash(error2), |
| 208 | hash(ValidationError("message", code="my_code1")), |
| 209 | ) |
| 210 | self.assertNotEqual( |
| 211 | hash(error2), |
| 212 | hash(ValidationError("other", code="my_code1")), |
| 213 | ) |
| 214 | self.assertNotEqual(hash(error2), hash(error3)) |
| 215 | self.assertNotEqual(hash(error2), hash(error4)) |
| 216 | self.assertNotEqual(hash(error2), hash(error5)) |
| 217 | self.assertNotEqual(hash(error2), hash(error6)) |
| 218 | self.assertNotEqual(hash(error2), hash(error7)) |
| 219 | |
| 220 | self.assertEqual( |
| 221 | hash(error4), |
| 222 | hash( |
| 223 | ValidationError( |
| 224 | "error %(parm1)s %(parm2)s", |
| 225 | code="my_code1", |
| 226 | params={"parm1": "val1", "parm2": "val2"}, |
| 227 | ) |
| 228 | ), |
| 229 | ) |
| 230 | self.assertNotEqual( |
| 231 | hash(error4), |
| 232 | hash( |
| 233 | ValidationError( |
| 234 | "error %(parm1)s %(parm2)s", |
| 235 | code="my_code2", |
| 236 | params={"parm1": "val1", "parm2": "val2"}, |
| 237 | ) |
| 238 | ), |
nothing calls this directly
no test coverage detected