Ticket #13400: 13400-better-doesnotexist-error-message-tests-fixed.diff

File 13400-better-doesnotexist-error-message-tests-fixed.diff, 6.4 KB (added by aaron, 15 years ago)

Same as previous patch, but with tests fixed.

  • django/db/models/query.py

     
    337337        if num == 1:
    338338            return clone._result_cache[0]
    339339        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            )
    342345        raise self.model.MultipleObjectsReturned("get() returned more than one %s -- it returned %s! Lookup parameters were %s"
    343346                % (self.model._meta.object_name, num, kwargs))
    344347
  • django/contrib/sites/tests.py

     
    1212>>> Site.objects.get_current()
    1313Traceback (most recent call last):
    1414...
    15 DoesNotExist: Site matching query does not exist.
     15DoesNotExist: Site matching query does not exist.  get() parameters were {'pk': 1}
    1616
    1717# After updating a Site object (e.g. via the admin), we shouldn't return a
    1818# bogus value from the SITE_CACHE.
  • tests/modeltests/custom_pk/models.py

     
    5858>>> Employee.objects.get(pk=42)
    5959Traceback (most recent call last):
    6060    ...
    61 DoesNotExist: Employee matching query does not exist.
     61DoesNotExist: Employee matching query does not exist.  get() parameters were {'pk': 42}
    6262
    6363# Use the name of the primary key, rather than pk.
    6464>>> Employee.objects.get(employee_code__exact=123)
  • tests/modeltests/model_inheritance/models.py

     
    294294>>> place.restaurant.italianrestaurant
    295295Traceback (most recent call last):
    296296    ...
    297 DoesNotExist: ItalianRestaurant matching query does not exist.
     297DoesNotExist: ItalianRestaurant matching query does not exist.  get() parameters were {'restaurant_ptr__pk': 3}
    298298
    299299# An ItalianRestaurant which does not exist is also a Place which does not exist.
    300300>>> try:
     
    323323>>> p.restaurant
    324324Traceback (most recent call last):
    325325    ...
    326 DoesNotExist: Restaurant matching query does not exist.
     326DoesNotExist: Restaurant matching query does not exist.  get() parameters were {'place_ptr__pk': 5}
    327327
    328328# But we can descend from p to the Supplier child, as expected.
    329329>>> p.supplier
  • tests/modeltests/basic/models.py

     
    100100>>> Article.objects.get(id__exact=2)
    101101Traceback (most recent call last):
    102102    ...
    103 DoesNotExist: Article matching query does not exist.
     103DoesNotExist: Article matching query does not exist.  get() parameters were {'id__exact': 2}
    104104
    105105>>> Article.objects.get(pub_date__year=2005, pub_date__month=8)
    106106Traceback (most recent call last):
    107107    ...
    108 DoesNotExist: Article matching query does not exist.
     108DoesNotExist: Article matching query does not exist.  get() parameters were {'pub_date__year': 2005, 'pub_date__month': 8}
    109109
    110110>>> Article.objects.get(pub_date__week_day=6)
    111111Traceback (most recent call last):
    112112    ...
    113 DoesNotExist: Article matching query does not exist.
     113DoesNotExist: Article matching query does not exist.  get() parameters were {'pub_date__week_day': 6}
    114114
    115115# Lookup by a primary key is the most common case, so Django provides a
    116116# shortcut for primary-key exact lookups.
  • tests/modeltests/one_to_one/models.py

     
    6969>>> p2.restaurant
    7070Traceback (most recent call last):
    7171    ...
    72 DoesNotExist: Restaurant matching query does not exist.
     72DoesNotExist: Restaurant matching query does not exist.  get() parameters were {'place__pk': 2}
    7373
    7474# Set the place using assignment notation. Because place is the primary key on
    7575# Restaurant, the save will create a new restaurant
  • tests/modeltests/get_latest/models.py

     
    3434>>> Article.objects.latest()
    3535Traceback (most recent call last):
    3636    ...
    37 DoesNotExist: Article matching query does not exist.
     37DoesNotExist: Article matching query does not exist.  get() parameters were {}
    3838
    3939# Create a couple of Articles.
    4040>>> from datetime import datetime
  • tests/regressiontests/model_inheritance_regress/models.py

     
    243243>>> Place.objects.get(pk=ident)
    244244Traceback (most recent call last):
    245245...
    246 DoesNotExist: Place matching query does not exist.
     246DoesNotExist: Place matching query does not exist.  get() parameters were {'pk': 1}
    247247
    248248>>> ItalianRestaurant.objects.get(pk=ident)
    249249Traceback (most recent call last):
    250250...
    251 DoesNotExist: ItalianRestaurant matching query does not exist.
     251DoesNotExist: ItalianRestaurant matching query does not exist.  get() parameters were {'pk': 1}
    252252
    253253# Regression test for #6755
    254254>>> r = Restaurant(serves_pizza=False)
  • tests/regressiontests/reverse_single_related/models.py

     
    4949>>> private_item.source
    5050Traceback (most recent call last):
    5151    ...
    52 DoesNotExist: Source matching query does not exist.
     52DoesNotExist: Source matching query does not exist.  get() parameters were {'id__exact': 2}
    5353
    5454"""}
Back to Top