Fixed #23682 -- Enhanced circular redirects detection in tests.

Please see [#23682](https://code.djangoproject.com/ticket/23682).
Do you think `RedirectCycleError` needs to be in the `django.test` namespace? I think we should try to keep the namespace cleaner if possible.