(self)
| 237 | |
| 238 | class LookupTests(TestCase): |
| 239 | def test_custom_name_lookup(self): |
| 240 | a1 = Author.objects.create(name="a1", birthdate=date(1981, 2, 16)) |
| 241 | Author.objects.create(name="a2", birthdate=date(2012, 2, 29)) |
| 242 | with ( |
| 243 | register_lookup(models.DateField, YearTransform), |
| 244 | register_lookup(models.DateField, YearTransform, lookup_name="justtheyear"), |
| 245 | register_lookup(YearTransform, Exactly), |
| 246 | register_lookup(YearTransform, Exactly, lookup_name="isactually"), |
| 247 | ): |
| 248 | qs1 = Author.objects.filter(birthdate__testyear__exactly=1981) |
| 249 | qs2 = Author.objects.filter(birthdate__justtheyear__isactually=1981) |
| 250 | self.assertSequenceEqual(qs1, [a1]) |
| 251 | self.assertSequenceEqual(qs2, [a1]) |
| 252 | |
| 253 | def test_custom_lookup_with_subquery(self): |
| 254 | class NotEqual(models.Lookup): |
nothing calls this directly
no test coverage detected