diff options
| author | Travis Jensen <travis.jensen@oracle.com> | 2015-09-17 19:37:16 -0600 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2015-09-19 15:05:54 +0200 |
| commit | 1a09b3c398b42800de864023dad872d83b196181 (patch) | |
| tree | 413369ac2225022a04278750bf063363cd1e643f /tests | |
| parent | 43f2eb7ef327126271a8c70d6fde5713947150a5 (diff) | |
Fixed #25424 -- Use force_str for test client URLs.
urlparse() fails with an AttributeError ("'__proxy__' object has no
attribute 'decode'") if reverse_lazy is used to look up the URL
(this is exactly the same problem that caused ticket #18776). The
solution is to use force_str() on the path before handing it to
urlparse().
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_client/tests.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py index 1a6a453d04..4b48332085 100644 --- a/tests/test_client/tests.py +++ b/tests/test_client/tests.py @@ -26,6 +26,7 @@ import datetime from django.contrib.auth.models import User from django.core import mail +from django.core.urlresolvers import reverse_lazy from django.http import HttpResponse from django.test import ( Client, RequestFactory, SimpleTestCase, TestCase, override_settings, @@ -623,6 +624,14 @@ class ClientTest(TestCase): self.assertEqual(mail.outbox[0].to[0], 'first@example.com') self.assertEqual(mail.outbox[0].to[1], 'second@example.com') + def test_reverse_lazy_decodes(self): + "Ensure reverse_lazy works in the test client" + data = {'var': 'data'} + response = self.client.get(reverse_lazy('get_view'), data) + + # Check some response details + self.assertContains(response, 'This is a test') + def test_mass_mail_sending(self): "Test that mass mail is redirected to a dummy outbox during test setup" |
