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
2f698cd9
Kaydet (Commit)
2f698cd9
authored
Nis 29, 2016
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #26428 -- Added support for relative path redirects to the test client.
Thanks iktyrrell for the patch.
üst
ffb1c532
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
3 deletions
+20
-3
client.py
django/test/client.py
+7
-2
1.9.6.txt
docs/releases/1.9.6.txt
+1
-1
tests.py
tests/test_client/tests.py
+12
-0
No files found.
django/test/client.py
Dosyayı görüntüle @
2f698cd9
...
@@ -26,7 +26,7 @@ from django.utils.encoding import force_bytes, force_str, uri_to_iri
...
@@ -26,7 +26,7 @@ from django.utils.encoding import force_bytes, force_str, uri_to_iri
from
django.utils.functional
import
SimpleLazyObject
,
curry
from
django.utils.functional
import
SimpleLazyObject
,
curry
from
django.utils.http
import
urlencode
from
django.utils.http
import
urlencode
from
django.utils.itercompat
import
is_iterable
from
django.utils.itercompat
import
is_iterable
from
django.utils.six.moves.urllib.parse
import
urlparse
,
urlsplit
from
django.utils.six.moves.urllib.parse
import
url
join
,
url
parse
,
urlsplit
__all__
=
(
'Client'
,
'RedirectCycleError'
,
'RequestFactory'
,
'encode_file'
,
'encode_multipart'
)
__all__
=
(
'Client'
,
'RedirectCycleError'
,
'RequestFactory'
,
'encode_file'
,
'encode_multipart'
)
...
@@ -699,7 +699,12 @@ class Client(RequestFactory):
...
@@ -699,7 +699,12 @@ class Client(RequestFactory):
if
url
.
port
:
if
url
.
port
:
extra
[
'SERVER_PORT'
]
=
str
(
url
.
port
)
extra
[
'SERVER_PORT'
]
=
str
(
url
.
port
)
response
=
self
.
get
(
url
.
path
,
QueryDict
(
url
.
query
),
follow
=
False
,
**
extra
)
# Prepend the request path to handle relative path redirects
path
=
url
.
path
if
not
path
.
startswith
(
'/'
):
path
=
urljoin
(
response
.
request
[
'PATH_INFO'
],
path
)
response
=
self
.
get
(
path
,
QueryDict
(
url
.
query
),
follow
=
False
,
**
extra
)
response
.
redirect_chain
=
redirect_chain
response
.
redirect_chain
=
redirect_chain
if
redirect_chain
[
-
1
]
in
redirect_chain
[:
-
1
]:
if
redirect_chain
[
-
1
]
in
redirect_chain
[:
-
1
]:
...
...
docs/releases/1.9.6.txt
Dosyayı görüntüle @
2f698cd9
...
@@ -9,7 +9,7 @@ Django 1.9.6 fixes several bugs in 1.9.5.
...
@@ -9,7 +9,7 @@ Django 1.9.6 fixes several bugs in 1.9.5.
Bugfixes
Bugfixes
========
========
* Added support for relative path redirects to
* Added support for relative path redirects to
the test client and to
``SimpleTestCase.assertRedirects()`` because Django 1.9 no longer converts
``SimpleTestCase.assertRedirects()`` because Django 1.9 no longer converts
redirects to absolute URIs (:ticket:`26428`).
redirects to absolute URIs (:ticket:`26428`).
...
...
tests/test_client/tests.py
Dosyayı görüntüle @
2f698cd9
...
@@ -198,6 +198,18 @@ class ClientTest(TestCase):
...
@@ -198,6 +198,18 @@ class ClientTest(TestCase):
self
.
assertRedirects
(
response
,
'/get_view/'
,
status_code
=
302
,
target_status_code
=
200
)
self
.
assertRedirects
(
response
,
'/get_view/'
,
status_code
=
302
,
target_status_code
=
200
)
self
.
assertEqual
(
len
(
response
.
redirect_chain
),
2
)
self
.
assertEqual
(
len
(
response
.
redirect_chain
),
2
)
def
test_follow_relative_redirect
(
self
):
"A URL with a relative redirect can be followed."
response
=
self
.
client
.
get
(
'/accounts/'
,
follow
=
True
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
request
[
'PATH_INFO'
],
'/accounts/login/'
)
def
test_follow_relative_redirect_no_trailing_slash
(
self
):
"A URL with a relative redirect with no trailing slash can be followed."
response
=
self
.
client
.
get
(
'/accounts/no_trailing_slash'
,
follow
=
True
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
request
[
'PATH_INFO'
],
'/accounts/login/'
)
def
test_redirect_http
(
self
):
def
test_redirect_http
(
self
):
"GET a URL that redirects to an http URI"
"GET a URL that redirects to an http URI"
response
=
self
.
client
.
get
(
'/http_redirect_view/'
,
follow
=
True
)
response
=
self
.
client
.
get
(
'/http_redirect_view/'
,
follow
=
True
)
...
...
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