              id__exact=2000,
          )
          # To avoid dict-ordering related errors check only one lookup
          # in single assert.
          self.assertRaises(
              ObjectDoesNotExist,
              Article.objects.get,
              pub_date__year=2005,
              pub_date__month=8,
          )
          six.assertRaisesRegex(
              self,
              ObjectDoesNotExist,
              "Article matching query does not exist.",
              Article.objects.get,
 
</s> remove         self.assertRaises(
            TypeError,
            Article.objects.dates,
        )
 </s> add         with self.assertRaises(TypeError):
            Article.objects.dates() </s> remove         self.assertRaises(
            AttributeError, getattr, post, "attached_%(class)s_set"
        )
 </s> add         with self.assertRaises(AttributeError):
            getattr(post, "attached_%(class)s_set") </s> remove         self.assertRaises(
            Place.DoesNotExist,
            ItalianRestaurant.objects.get, name="The Noodle Void"
        )
 </s> add         with self.assertRaises(Place.DoesNotExist):
            ItalianRestaurant.objects.get(name="The Noodle Void") </s> remove         self.assertRaises(
            ItalianRestaurant.DoesNotExist,
            lambda: Place.objects.get(name="Demon Dogs").restaurant.italianrestaurant
        )
 </s> add         with self.assertRaises(ItalianRestaurant.DoesNotExist):
            Place.objects.get(name="Demon Dogs").restaurant.italianrestaurant </s> remove         self.assertRaises(
            FieldError,
            lambda: Book.objects.all().aggregate(num_authors=Count('foo'))
        )
 </s> add         with self.assertRaises(FieldError):
            Book.objects.all().aggregate(num_authors=Count('foo'))
        with self.assertRaises(ObjectDoesNotExist):
            Article.objects.get(pub_date__year=2005, pub_date__month=8)
              id__exact=2000,
          )
          # To avoid dict-ordering related errors check only one lookup
          # in single assert.
        with self.assertRaises(ObjectDoesNotExist):
            Article.objects.get(pub_date__year=2005, pub_date__month=8)
        with self.assertRaises(ObjectDoesNotExist):
            Article.objects.get(pub_date__year=2005, pub_date__month=8)
        with self.assertRaises(ObjectDoesNotExist):
            Article.objects.get(pub_date__year=2005, pub_date__month=8)
        with self.assertRaises(ObjectDoesNotExist):
            Article.objects.get(pub_date__year=2005, pub_date__month=8)
        with self.assertRaises(ObjectDoesNotExist):
            Article.objects.get(pub_date__year=2005, pub_date__month=8)
        with self.assertRaises(ObjectDoesNotExist):
            Article.objects.get(pub_date__year=2005, pub_date__month=8)
          six.assertRaisesRegex(
              self,
              ObjectDoesNotExist,
              "Article matching query does not exist.",
              Article.objects.get,
keep keep keep keep replace replace replace replace replace replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/basic/tests.py