      def test_dateTimeField_with_inputformat(self):
          "DateTimeFields with manually specified input formats can accept those formats"
          f = forms.DateTimeField(input_formats=["%I:%M:%S %p %d.%m.%Y", "%I:%M %p %d-%m-%Y"])
          # Parse a date in an unaccepted format; get an error
          self.assertRaises(forms.ValidationError, f.clean, '2010-12-21 13:30:05')
  
          # Parse a date in a valid format, get a parsed result
          result = f.clean('1:30:05 PM 21.12.2010')
          self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
  
 
</s> remove         self.assertRaises(forms.ValidationError, f.clean, '2010-12-21 13:30:05')
 </s> add         with self.assertRaises(forms.ValidationError):
            f.clean('2010-12-21 13:30:05') </s> remove         self.assertRaises(forms.ValidationError, f.clean, '13:30:05 21.12.2010')
 </s> add         with self.assertRaises(forms.ValidationError):
            f.clean('13:30:05 21.12.2010') </s> remove         self.assertRaises(Http404, get_object_or_404, Article, title="Foo")
 </s> add         with self.assertRaises(Http404):
            get_object_or_404(Article, title="Foo") </s> remove         self.assertRaises(InvalidPage, paginator.page, 3)
        self.assertRaises(PageNotAnInteger, paginator.validate_number, None)
        self.assertRaises(PageNotAnInteger, paginator.validate_number, 'x')
 </s> add         with self.assertRaises(InvalidPage):
            paginator.page(3)
        with self.assertRaises(PageNotAnInteger):
            paginator.validate_number(None)
        with self.assertRaises(PageNotAnInteger):
            paginator.validate_number('x') </s> remove         self.assertRaises(TypeError, lambda: Author.objects.raw(query)['test'])
 </s> add         with self.assertRaises(TypeError):
            Author.objects.raw(query)['test']
        with self.assertRaises(forms.ValidationError):
            f.clean('2010-12-21 13:30:05')
      def test_dateTimeField_with_inputformat(self):
          "DateTimeFields with manually specified input formats can accept those formats"
          f = forms.DateTimeField(input_formats=["%I:%M:%S %p %d.%m.%Y", "%I:%M %p %d-%m-%Y"])
          # Parse a date in an unaccepted format; get an error
        with self.assertRaises(forms.ValidationError):
            f.clean('2010-12-21 13:30:05')
  
          # Parse a date in a valid format, get a parsed result
          result = f.clean('1:30:05 PM 21.12.2010')
          self.assertEqual(result, datetime(2010, 12, 21, 13, 30, 5))
  
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/forms_tests/tests/test_input_formats.py