Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
d2569f89
Kaydet (Commit)
d2569f89
authored
Nis 02, 2016
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26428 -- Added support for relative path redirects in assertRedirects().
Thanks Trac alias master for the report and review.
üst
55c843f2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
2 deletions
+19
-2
testcases.py
django/test/testcases.py
+6
-1
1.9.6.txt
docs/releases/1.9.6.txt
+3
-1
tests.py
tests/test_client/tests.py
+8
-0
urls.py
tests/test_client/urls.py
+2
-0
No files found.
django/test/testcases.py
Dosyayı görüntüle @
d2569f89
...
...
@@ -41,7 +41,7 @@ from django.utils.decorators import classproperty
from
django.utils.deprecation
import
RemovedInDjango20Warning
from
django.utils.encoding
import
force_text
from
django.utils.six.moves.urllib.parse
import
(
unquote
,
urlparse
,
urlsplit
,
urlunsplit
,
unquote
,
url
join
,
url
parse
,
urlsplit
,
urlunsplit
,
)
from
django.utils.six.moves.urllib.request
import
url2pathname
from
django.views.static
import
serve
...
...
@@ -291,6 +291,11 @@ class SimpleTestCase(unittest.TestCase):
url
=
response
.
url
scheme
,
netloc
,
path
,
query
,
fragment
=
urlsplit
(
url
)
# Prepend the request path to handle relative path redirects.
if
not
path
.
startswith
(
'/'
):
url
=
urljoin
(
response
.
request
[
'PATH_INFO'
],
url
)
path
=
urljoin
(
response
.
request
[
'PATH_INFO'
],
path
)
if
fetch_redirect_response
:
redirect_response
=
response
.
client
.
get
(
path
,
QueryDict
(
query
),
secure
=
(
scheme
==
'https'
))
...
...
docs/releases/1.9.6.txt
Dosyayı görüntüle @
d2569f89
...
...
@@ -9,4 +9,6 @@ Django 1.9.6 fixes several bugs in 1.9.5.
Bugfixes
========
* ...
* Added support for relative path redirects to
``SimpleTestCase.assertRedirects()`` because Django 1.9 no longer converts
redirects to absolute URIs (:ticket:`26428`).
tests/test_client/tests.py
Dosyayı görüntüle @
d2569f89
...
...
@@ -623,6 +623,14 @@ class ClientTest(TestCase):
# Check some response details
self
.
assertContains
(
response
,
'This is a test'
)
def
test_relative_redirect
(
self
):
response
=
self
.
client
.
get
(
'/accounts/'
)
self
.
assertRedirects
(
response
,
'/accounts/login/'
)
def
test_relative_redirect_no_trailing_slash
(
self
):
response
=
self
.
client
.
get
(
'/accounts/no_trailing_slash'
)
self
.
assertRedirects
(
response
,
'/accounts/login/'
)
def
test_mass_mail_sending
(
self
):
"Test that mass mail is redirected to a dummy outbox during test setup"
...
...
tests/test_client/urls.py
Dosyayı görüntüle @
d2569f89
...
...
@@ -34,6 +34,8 @@ urlpatterns = [
url
(
r'^nesting_exception_view/$'
,
views
.
nesting_exception_view
),
url
(
r'^django_project_redirect/$'
,
views
.
django_project_redirect
),
url
(
r'^accounts/$'
,
RedirectView
.
as_view
(
url
=
'login/'
)),
url
(
r'^accounts/no_trailing_slash$'
,
RedirectView
.
as_view
(
url
=
'login/'
)),
url
(
r'^accounts/login/$'
,
auth_views
.
login
,
{
'template_name'
:
'login.html'
}),
url
(
r'^accounts/logout/$'
,
auth_views
.
logout
),
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment