0
0
mirror of https://github.com/django/django.git synced 2024-11-27 17:16:33 +01:00
django/tests/utils_tests/test_itercompat.py
Simon Charette 57307bbc7d Fixed #35666 -- Documented stacklevel usage and testing, and adjusted test suite accordingly.
Over the years we've had multiple instances of hit and misses when
emitting warnings: either setting the wrong stacklevel or not setting
it at all.

This work adds assertions for the existing warnings that were declaring
the correct stacklevel, but were lacking tests for it.
2024-08-28 11:44:05 -03:00

17 lines
605 B
Python

# RemovedInDjango60Warning: Remove this entire module.
from django.test import SimpleTestCase
from django.utils.deprecation import RemovedInDjango60Warning
from django.utils.itercompat import is_iterable
class TestIterCompat(SimpleTestCase):
def test_is_iterable_deprecation(self):
msg = (
"django.utils.itercompat.is_iterable() is deprecated. "
"Use isinstance(..., collections.abc.Iterable) instead."
)
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
is_iterable([])
self.assertEqual(ctx.filename, __file__)