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
0f454f5d
Kaydet (Commit)
0f454f5d
authored
Ara 16, 2016
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #23960 -- Removed the host parameter for SimpleTestCase.assertRedirects().
Per deprecation timeline.
üst
f032bbc8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
38 deletions
+7
-38
testcases.py
django/test/testcases.py
+2
-21
2.0.txt
docs/releases/2.0.txt
+4
-0
tools.txt
docs/topics/testing/tools.txt
+0
-5
tests.py
tests/test_client_regress/tests.py
+1
-12
No files found.
django/test/testcases.py
Dosyayı görüntüle @
0f454f5d
...
...
@@ -39,7 +39,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
,
urljoin
,
urlparse
,
urlsplit
,
urlunsplit
,
unquote
,
urljoin
,
urlparse
,
urlsplit
,
)
from
django.utils.six.moves.urllib.request
import
url2pathname
from
django.views.static
import
serve
...
...
@@ -245,7 +245,7 @@ class SimpleTestCase(unittest.TestCase):
return
modify_settings
(
**
kwargs
)
def
assertRedirects
(
self
,
response
,
expected_url
,
status_code
=
302
,
target_status_code
=
200
,
host
=
None
,
msg_prefix
=
''
,
target_status_code
=
200
,
msg_prefix
=
''
,
fetch_redirect_response
=
True
):
"""Asserts that a response redirected to a specific URL, and that the
redirect URL can be loaded.
...
...
@@ -254,12 +254,6 @@ class SimpleTestCase(unittest.TestCase):
TestClient to do a request (use fetch_redirect_response=False to check
such links without fetching them).
"""
if
host
is
not
None
:
warnings
.
warn
(
"The host argument is deprecated and no longer used by assertRedirects"
,
RemovedInDjango20Warning
,
stacklevel
=
2
)
if
msg_prefix
:
msg_prefix
+=
": "
...
...
@@ -324,19 +318,6 @@ class SimpleTestCase(unittest.TestCase):
%
(
path
,
redirect_response
.
status_code
,
target_status_code
)
)
if
url
!=
expected_url
:
# For temporary backwards compatibility, try to compare with a relative url
e_scheme
,
e_netloc
,
e_path
,
e_query
,
e_fragment
=
urlsplit
(
expected_url
)
relative_url
=
urlunsplit
((
''
,
''
,
e_path
,
e_query
,
e_fragment
))
if
url
==
relative_url
:
warnings
.
warn
(
"assertRedirects had to strip the scheme and domain from the "
"expected URL, as it was always added automatically to URLs "
"before Django 1.9. Please update your expected URLs by "
"removing the scheme and domain."
,
RemovedInDjango20Warning
,
stacklevel
=
2
)
expected_url
=
relative_url
self
.
assertEqual
(
url
,
expected_url
,
msg_prefix
+
"Response redirected to '
%
s', expected '
%
s'"
%
(
url
,
expected_url
)
...
...
docs/releases/2.0.txt
Dosyayı görüntüle @
0f454f5d
...
...
@@ -243,3 +243,7 @@ these features.
* The ``django.forms.extras`` package is removed.
* The ``assignment_tag`` helper is removed.
* The ``host`` argument to ``SimpleTestCase.assertsRedirects()`` is removed.
The compatibility layer which allows absolute URLs to be considered equal to
relative ones when the path is identical is also removed.
docs/topics/testing/tools.txt
Dosyayı görüntüle @
0f454f5d
...
...
@@ -1479,11 +1479,6 @@ your test suite.
the original request's scheme is used. If present, the scheme in
``expected_url`` is the one used to make the comparisons to.
.. deprecated:: 1.9
The ``host`` argument is deprecated, as redirections are no longer
forced to be absolute URLs.
.. method:: SimpleTestCase.assertHTMLEqual(html1, html2, msg=None)
Asserts that the strings ``html1`` and ``html2`` are equal. The comparison
...
...
tests/test_client_regress/tests.py
Dosyayı görüntüle @
0f454f5d
...
...
@@ -15,14 +15,12 @@ from django.template import (
)
from
django.template.response
import
SimpleTemplateResponse
from
django.test
import
(
Client
,
SimpleTestCase
,
TestCase
,
ignore_warnings
,
modify_settings
,
override_settings
,
Client
,
SimpleTestCase
,
TestCase
,
modify_settings
,
override_settings
,
)
from
django.test.client
import
RedirectCycleError
,
RequestFactory
,
encode_file
from
django.test.utils
import
ContextList
,
str_prefix
from
django.urls
import
NoReverseMatch
,
reverse
from
django.utils._os
import
upath
from
django.utils.deprecation
import
RemovedInDjango20Warning
from
django.utils.translation
import
ugettext_lazy
from
.models
import
CustomUser
...
...
@@ -514,15 +512,6 @@ class AssertRedirectsTests(SimpleTestCase):
with
self
.
assertRaises
(
AssertionError
):
self
.
assertRedirects
(
response
,
'http://testserver/secure_view/'
,
status_code
=
302
)
@ignore_warnings
(
category
=
RemovedInDjango20Warning
)
def
test_full_path_in_expected_urls
(
self
):
"""
Specifying a full URL as assertRedirects expected_url still
work as backwards compatible behavior until Django 2.0.
"""
response
=
self
.
client
.
get
(
'/redirect_view/'
)
self
.
assertRedirects
(
response
,
'http://testserver/get_view/'
)
@override_settings
(
ROOT_URLCONF
=
'test_client_regress.urls'
)
class
AssertFormErrorTests
(
SimpleTestCase
):
...
...
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