#35986: Test classes with @translation.override decorator are not run
----------------------------------+------------------------------------
     Reporter:  Arthur Pemberton  |                    Owner:  (none)
         Type:  Bug               |                   Status:  new
    Component:  Utilities         |                  Version:  5.1
     Severity:  Normal            |               Resolution:
     Keywords:                    |             Triage Stage:  Accepted
    Has patch:  0                 |      Needs documentation:  0
  Needs tests:  0                 |  Patch needs improvement:  0
Easy pickings:  0                 |                    UI/UX:  0
----------------------------------+------------------------------------
Comment (by Simon Charette):

 Tests appears to pass even with the `timezone.override` adjustments

 {{{#!diff
 diff --git a/tests/forms_tests/tests/test_input_formats.py
 b/tests/forms_tests/tests/test_input_formats.py
 index c5023d8d10..30ca53ba4b 100644
 --- a/tests/forms_tests/tests/test_input_formats.py
 +++ b/tests/forms_tests/tests/test_input_formats.py
 @@ -118,9 +118,13 @@ def test_localized_timeField_with_inputformat(self):
          self.assertEqual(text, "13:30:00")


 [email protected](None)
  @override_settings(TIME_INPUT_FORMATS=["%I:%M:%S %p", "%I:%M %p"])
  class CustomTimeInputFormatsTests(SimpleTestCase):
 +    @classmethod
 +    def setUpClass(cls):
 +        cls.enterClassContext(translation.override(None))
 +        super().setUpClass()
 +
      def test_timeField(self):
          "TimeFields can parse dates in the default format"
          f = forms.TimeField()
 @@ -431,9 +435,13 @@ def test_localized_dateField_with_inputformat(self):
          self.assertEqual(text, "21.12.2010")


 [email protected](None)
  @override_settings(DATE_INPUT_FORMATS=["%d.%m.%Y", "%d-%m-%Y"])
  class CustomDateInputFormatsTests(SimpleTestCase):
 +    @classmethod
 +    def setUpClass(cls):
 +        cls.enterClassContext(translation.override(None))
 +        super().setUpClass()
 +
      def test_dateField(self):
          "DateFields can parse dates in the default format"
          f = forms.DateField()
 @@ -752,9 +760,13 @@ def
 test_localized_dateTimeField_with_inputformat(self):
          self.assertEqual(text, "21.12.2010 13:30:00")


 [email protected](None)
  @override_settings(DATETIME_INPUT_FORMATS=["%I:%M:%S %p %d/%m/%Y", "%I:%M
 %p %d-%m-%Y"])
  class CustomDateTimeInputFormatsTests(SimpleTestCase):
 +    @classmethod
 +    def setUpClass(cls):
 +        cls.enterClassContext(translation.override(None))
 +        super().setUpClass()
 +
      def test_dateTimeField(self):
          "DateTimeFields can parse dates in the default format"
          f = forms.DateTimeField()
 diff --git a/tests/timezones/tests.py b/tests/timezones/tests.py
 index c45f078ef6..c66c9a9c75 100644
 --- a/tests/timezones/tests.py
 +++ b/tests/timezones/tests.py
 @@ -921,9 +921,13 @@ def test_aware_datetime_in_other_timezone(self):
                  self.assertEqual(obj.dt, dt)


 [email protected](None)
  @override_settings(DATETIME_FORMAT="c", TIME_ZONE="Africa/Nairobi",
 USE_TZ=True)
  class TemplateTests(SimpleTestCase):
 +    @classmethod
 +    def setUpClass(cls):
 +        cls.enterClassContext(translation.override(None))
 +        super().setUpClass()
 +
      @requires_tz_support
      def test_localtime_templatetag_and_filters(self):
          """
 @@ -1324,7 +1328,6 @@ def test_localized_model_form(self):
              self.assertIn("2011-09-01 17:20:30", str(form))


 [email protected](None)
  @override_settings(
      DATETIME_FORMAT="c",
      TIME_ZONE="Africa/Nairobi",
 @@ -1334,6 +1337,7 @@ def test_localized_model_form(self):
  class AdminTests(TestCase):
      @classmethod
      def setUpTestData(cls):
 +        cls.enterClassContext(translation.override(None))
          cls.u1 = User.objects.create_user(
              password="secret",
              last_login=datetime.datetime(2007, 5, 30, 13, 20, 10,
 tzinfo=UTC),
 @@ -1403,3 +1407,4 @@ def test_change_readonly_in_other_timezone(self):
                  reverse("admin_tz:timezones_timestamp_change",
 args=(t.pk,))
              )
          self.assertContains(response,
 t.created.astimezone(ICT).isoformat())
 +        self.assertContains(response,
 t.created.astimezone(ICT).isoformat())
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35986#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070193c4406f1c-e4865e3b-600e-4108-b7dd-8c481901913f-000000%40eu-central-1.amazonses.com.

Reply via email to