assertQuerySetEqual checks the number of appearance of each item when used with option ordered=False.
(self)
| 331 | self.assertQuerySetEqual(Person.objects.filter(name="p1"), [self.p1]) |
| 332 | |
| 333 | def test_repeated_values(self): |
| 334 | """ |
| 335 | assertQuerySetEqual checks the number of appearance of each item |
| 336 | when used with option ordered=False. |
| 337 | """ |
| 338 | batmobile = Car.objects.create(name="Batmobile") |
| 339 | k2000 = Car.objects.create(name="K 2000") |
| 340 | PossessedCar.objects.bulk_create( |
| 341 | [ |
| 342 | PossessedCar(car=batmobile, belongs_to=self.p1), |
| 343 | PossessedCar(car=batmobile, belongs_to=self.p1), |
| 344 | PossessedCar(car=k2000, belongs_to=self.p1), |
| 345 | PossessedCar(car=k2000, belongs_to=self.p1), |
| 346 | PossessedCar(car=k2000, belongs_to=self.p1), |
| 347 | PossessedCar(car=k2000, belongs_to=self.p1), |
| 348 | ] |
| 349 | ) |
| 350 | with self.assertRaises(AssertionError): |
| 351 | self.assertQuerySetEqual( |
| 352 | self.p1.cars.all(), [batmobile, k2000], ordered=False |
| 353 | ) |
| 354 | self.assertQuerySetEqual( |
| 355 | self.p1.cars.all(), [batmobile] * 2 + [k2000] * 4, ordered=False |
| 356 | ) |
| 357 | |
| 358 | def test_maxdiff(self): |
| 359 | names = ["Joe Smith %s" % i for i in range(20)] |
nothing calls this directly
no test coverage detected