          self.assertEqual(e.pk, 123)
          # Or we can use the real attribute name for the primary key:
          self.assertEqual(e.employee_code, 123)
  
          self.assertRaises(AttributeError, lambda: e.id)
  
      def test_in_bulk(self):
          """
          Custom pks work with in_bulk, both for integer and non-integer types
          """
 
</s> remove         self.assertRaises(
            Employee.DoesNotExist,
            lambda: Employee.objects.get(pk=42)
        )
 </s> add         with self.assertRaises(Employee.DoesNotExist):
            Employee.objects.get(pk=42) </s> remove         self.assertRaises(FieldError, Poll.objects.get,
            choice__name__exact="This is the answer")
 </s> add         with self.assertRaises(FieldError):
            Poll.objects.get(choice__name__exact="This is the answer") </s> remove         self.assertRaises(AttributeError, lambda: Book.objects)
 </s> add         with self.assertRaises(AttributeError):
            Book.objects </s> remove         self.assertRaises(
            Place.DoesNotExist,
            Place.objects.get,
            pk=ident)
        self.assertRaises(
            ItalianRestaurant.DoesNotExist,
            ItalianRestaurant.objects.get,
            pk=ident)
 </s> add         with self.assertRaises(Place.DoesNotExist):
            Place.objects.get(pk=ident)
        with self.assertRaises(ItalianRestaurant.DoesNotExist):
            ItalianRestaurant.objects.get(pk=ident) </s> remove         self.assertRaises(NoReverseMatch, lambda: reverse('first'))
        self.assertRaises(NoReverseMatch, lambda: reverse('second'))
 </s> add         with self.assertRaises(NoReverseMatch):
            reverse('first')
        with self.assertRaises(NoReverseMatch):
            reverse('second')
        with self.assertRaises(AttributeError):
            e.id
          self.assertEqual(e.pk, 123)
          # Or we can use the real attribute name for the primary key:
          self.assertEqual(e.employee_code, 123)
  
        with self.assertRaises(AttributeError):
            e.id
  
      def test_in_bulk(self):
          """
          Custom pks work with in_bulk, both for integer and non-integer types
          """
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/custom_pk/tests.py