#21977: Deprecate SimpleTestCase.urls in favor of override_settings
-------------------------------------+-------------------------------------
     Reporter:  timo                 |                    Owner:
         Type:                       |  anubhav9042
  Cleanup/optimization               |                   Status:  assigned
    Component:  Testing framework    |                  Version:  master
     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
-------------------------------------+-------------------------------------
Changes (by loic84):

 * cc: loic@… (added)


Comment:

 I did a quick run with `-Wall` and found a couple of `SimpleTestCase.urls`
 that needed updating. Running the test suite with `--selenium` found a
 couple more, so there may be more skipped tests that need updating. I
 guess the logs of the CI will have to be monitored on the various setups.

 The `stacklevel` for this warning isn't helpful at all, I've tried levels
 up to 6 with no luck, so the faulty `TestCase` really need to be specified
 in the warning message. For some reason `-Werror` doesn't do anything
 here, so the warning message is really the only indication one has to find
 the guilty `TestCase`.

 Testing the deprecation is not that easy, I came up with:

 {{{
 class DeprecatingSimpleTestCaseUrls(unittest.TestCase):
     def test_deprecation(self):
         class TempTestCase(SimpleTestCase):
             urls = 'tests.urls'

             def test(self):
                 pass

         with warnings.catch_warnings(record=True) as recorded:
             suite =
 unittest.TestLoader().loadTestsFromTestCase(TempTestCase)
             with open(os.devnull, 'w') as devnull:
                 unittest.TextTestRunner(stream=devnull,
 verbosity=2).run(suite)

         # FIXME: Check that the correct warning is raised.
         self.assertTrue(recorded)
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21977#comment:10>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/062.b5699c4e71a660e78bbe3bf8f1159cc8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to