Ticket #13400: 13400-better-doesnotexist-error-message-tests-fixed.diff
File 13400-better-doesnotexist-error-message-tests-fixed.diff, 6.4 KB (added by , 15 years ago) |
---|
-
django/db/models/query.py
337 337 if num == 1: 338 338 return clone._result_cache[0] 339 339 if not num: 340 raise self.model.DoesNotExist("%s matching query does not exist." 341 % self.model._meta.object_name) 340 raise self.model.DoesNotExist( 341 "%s matching query does not exist. " 342 "get() parameters were %s" 343 % (self.model._meta.object_name, kwargs) 344 ) 342 345 raise self.model.MultipleObjectsReturned("get() returned more than one %s -- it returned %s! Lookup parameters were %s" 343 346 % (self.model._meta.object_name, num, kwargs)) 344 347 -
django/contrib/sites/tests.py
12 12 >>> Site.objects.get_current() 13 13 Traceback (most recent call last): 14 14 ... 15 DoesNotExist: Site matching query does not exist. 15 DoesNotExist: Site matching query does not exist. get() parameters were {'pk': 1} 16 16 17 17 # After updating a Site object (e.g. via the admin), we shouldn't return a 18 18 # bogus value from the SITE_CACHE. -
tests/modeltests/custom_pk/models.py
58 58 >>> Employee.objects.get(pk=42) 59 59 Traceback (most recent call last): 60 60 ... 61 DoesNotExist: Employee matching query does not exist. 61 DoesNotExist: Employee matching query does not exist. get() parameters were {'pk': 42} 62 62 63 63 # Use the name of the primary key, rather than pk. 64 64 >>> Employee.objects.get(employee_code__exact=123) -
tests/modeltests/model_inheritance/models.py
294 294 >>> place.restaurant.italianrestaurant 295 295 Traceback (most recent call last): 296 296 ... 297 DoesNotExist: ItalianRestaurant matching query does not exist. 297 DoesNotExist: ItalianRestaurant matching query does not exist. get() parameters were {'restaurant_ptr__pk': 3} 298 298 299 299 # An ItalianRestaurant which does not exist is also a Place which does not exist. 300 300 >>> try: … … 323 323 >>> p.restaurant 324 324 Traceback (most recent call last): 325 325 ... 326 DoesNotExist: Restaurant matching query does not exist. 326 DoesNotExist: Restaurant matching query does not exist. get() parameters were {'place_ptr__pk': 5} 327 327 328 328 # But we can descend from p to the Supplier child, as expected. 329 329 >>> p.supplier -
tests/modeltests/basic/models.py
100 100 >>> Article.objects.get(id__exact=2) 101 101 Traceback (most recent call last): 102 102 ... 103 DoesNotExist: Article matching query does not exist. 103 DoesNotExist: Article matching query does not exist. get() parameters were {'id__exact': 2} 104 104 105 105 >>> Article.objects.get(pub_date__year=2005, pub_date__month=8) 106 106 Traceback (most recent call last): 107 107 ... 108 DoesNotExist: Article matching query does not exist. 108 DoesNotExist: Article matching query does not exist. get() parameters were {'pub_date__year': 2005, 'pub_date__month': 8} 109 109 110 110 >>> Article.objects.get(pub_date__week_day=6) 111 111 Traceback (most recent call last): 112 112 ... 113 DoesNotExist: Article matching query does not exist. 113 DoesNotExist: Article matching query does not exist. get() parameters were {'pub_date__week_day': 6} 114 114 115 115 # Lookup by a primary key is the most common case, so Django provides a 116 116 # shortcut for primary-key exact lookups. -
tests/modeltests/one_to_one/models.py
69 69 >>> p2.restaurant 70 70 Traceback (most recent call last): 71 71 ... 72 DoesNotExist: Restaurant matching query does not exist. 72 DoesNotExist: Restaurant matching query does not exist. get() parameters were {'place__pk': 2} 73 73 74 74 # Set the place using assignment notation. Because place is the primary key on 75 75 # Restaurant, the save will create a new restaurant -
tests/modeltests/get_latest/models.py
34 34 >>> Article.objects.latest() 35 35 Traceback (most recent call last): 36 36 ... 37 DoesNotExist: Article matching query does not exist. 37 DoesNotExist: Article matching query does not exist. get() parameters were {} 38 38 39 39 # Create a couple of Articles. 40 40 >>> from datetime import datetime -
tests/regressiontests/model_inheritance_regress/models.py
243 243 >>> Place.objects.get(pk=ident) 244 244 Traceback (most recent call last): 245 245 ... 246 DoesNotExist: Place matching query does not exist. 246 DoesNotExist: Place matching query does not exist. get() parameters were {'pk': 1} 247 247 248 248 >>> ItalianRestaurant.objects.get(pk=ident) 249 249 Traceback (most recent call last): 250 250 ... 251 DoesNotExist: ItalianRestaurant matching query does not exist. 251 DoesNotExist: ItalianRestaurant matching query does not exist. get() parameters were {'pk': 1} 252 252 253 253 # Regression test for #6755 254 254 >>> r = Restaurant(serves_pizza=False) -
tests/regressiontests/reverse_single_related/models.py
49 49 >>> private_item.source 50 50 Traceback (most recent call last): 51 51 ... 52 DoesNotExist: Source matching query does not exist. 52 DoesNotExist: Source matching query does not exist. get() parameters were {'id__exact': 2} 53 53 54 54 """}