According to docs:
https://docs.python.org/3/library/unittest.html#unittest.TestCase.addClassCleanup
> Add a function to be called after tearDownClass() to cleanup resources
used during the test class. Functions will be called in reverse order to
the order they are added (LIFO).
This was revealed with recent change in pytest (`8.2.0`):
> pytest-dev/pytest#11728: For unittest-based tests, exceptions during
class cleanup (as raised by functions registered with
TestCase.addClassCleanup) are now reported instead of silently failing.
`check_urlpatterns` is called before `cleanup_url_patterns` and fails
(problem was hidden by `pytest < 8.2.0`).
`doClassCleanups` can be used instead to check after-cleanup state:
https://docs.python.org/3/library/unittest.html#unittest.TestCase.doClassCleanups
> This method is called unconditionally after tearDownClass(), or after
setUpClass() if setUpClass() raises an exception.
It is responsible for calling all the cleanup functions added by
addClassCleanup(). If you need cleanup functions to be called prior to
tearDownClass() then you can call doClassCleanups() yourself.
Fixes: https://github.com/encode/django-rest-framework/issues/9399
Signed-off-by: Stanislav Levin <slev@altlinux.org>
* Add retain test data on follow=True
* Simplify TestAPITestClient.test_follow_redirect
Inspired from Django's ClientTest.test_follow_307_and_308_redirect
* Add 307 308 follow redirect test
* url() is deprecated in Django 3.1
* update given feedbacks on url() is deprecated in Django 3.1
* Fix test_urlpatterns.py to continue testing mixed re_path() and path()
* Fix one missed reference
Co-authored-by: sanjusci <sanju.sci9@gmail.com>
Thanks to Jon Dufresne (@jdufresne) for review.
Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
Co-authored-by: Rizwan Mansuri <Rizwan@webbyfox.com>
* Added TEMPLATES setting to tests
* Remove deprecated view-string in URL conf
* Replace 'urls = ...' in test classes with override_settings('ROOT_URLCONF=...')
* Refactor UsingURLPatterns to use override_settings(ROOT_URLCONF=...) style
* Get model managers and names in a version-compatible manner.
* Apply override_settings to a TestCase, not a mixin class
* Use '.callback' property instead of private attributes when inspecting urlpatterns
* Pass 'user' to template explicitly
* Correct sorting of import statements.
* Remove unused TEMPLATE_LOADERS setting, in favor of TEMPLATES.
* Remove code style issue
* BaseFilter test requires a concrete model
* Resolve tox.ini issues
* Resolve isort differences between local and tox environments
* Get rid of runtests.py
* Moved test code from rest_framework/tests and rest_framework/runtests to tests
* Invoke py.test from setup.py
* Invoke py.test from Travis
* Invoke py.test from tox
* Changed setUpClass to be just plain setUp in test_permissions.py
* Updated contribution guideline to show how to invoke py.test