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
1392aff4
Kaydet (Commit)
1392aff4
authored
Agu 18, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #21977 -- Removed SimpleTestCase.urls per deprecation timeline.
üst
5c62887d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
89 deletions
+9
-89
testcases.py
django/test/testcases.py
+3
-28
1.8.txt
docs/releases/1.8.txt
+4
-4
tools.txt
docs/topics/testing/tools.txt
+2
-30
tests.py
tests/deprecation/tests.py
+0
-27
No files found.
django/test/testcases.py
Dosyayı görüntüle @
1392aff4
...
...
@@ -26,7 +26,6 @@ from django.core.management import call_command
from
django.core.management.color
import
no_style
from
django.core.management.sql
import
emit_post_migrate_signal
from
django.core.servers.basehttp
import
WSGIRequestHandler
,
WSGIServer
from
django.core.urlresolvers
import
clear_url_caches
,
set_urlconf
from
django.db
import
DEFAULT_DB_ALIAS
,
connection
,
connections
,
transaction
from
django.forms.fields
import
CharField
from
django.http
import
QueryDict
...
...
@@ -39,9 +38,7 @@ from django.test.utils import (
)
from
django.utils
import
six
from
django.utils.decorators
import
classproperty
from
django.utils.deprecation
import
(
RemovedInDjango20Warning
,
RemovedInDjango110Warning
,
)
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
,
...
...
@@ -227,33 +224,11 @@ class SimpleTestCase(unittest.TestCase):
* Clearing the mail test outbox.
"""
self
.
client
=
self
.
client_class
()
self
.
_urlconf_setup
()
mail
.
outbox
=
[]
def
_urlconf_setup
(
self
):
if
hasattr
(
self
,
'urls'
):
warnings
.
warn
(
"SimpleTestCase.urls is deprecated and will be removed in "
"Django 1.10. Use @override_settings(ROOT_URLCONF=...) "
"in
%
s instead."
%
self
.
__class__
.
__name__
,
RemovedInDjango110Warning
,
stacklevel
=
2
)
set_urlconf
(
None
)
self
.
_old_root_urlconf
=
settings
.
ROOT_URLCONF
settings
.
ROOT_URLCONF
=
self
.
urls
clear_url_caches
()
def
_post_teardown
(
self
):
"""Performs any post-test things. This includes:
* Putting back the original ROOT_URLCONF if it was changed.
"""
self
.
_urlconf_teardown
()
def
_urlconf_teardown
(
self
):
if
hasattr
(
self
,
'_old_root_urlconf'
):
set_urlconf
(
None
)
settings
.
ROOT_URLCONF
=
self
.
_old_root_urlconf
clear_url_caches
()
"""Perform any post-test things."""
pass
def
settings
(
self
,
**
kwargs
):
"""
...
...
docs/releases/1.8.txt
Dosyayı görüntüle @
1392aff4
...
...
@@ -1307,10 +1307,10 @@ Built-in template context processors have been moved to
``django.test.SimpleTestCase.urls``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The attribute
:attr:`SimpleTestCase.urls <django.test.SimpleTestCase.urls>`
for specifying URLconf configuration in tests has been deprecated and will b
e
removed in Django 1.10. Use :func:`@override_settings(ROOT_URLCONF=...)
<django.test.override_settings>`
instead.
The attribute
``SimpleTestCase.urls`` for specifying URLconf configuration in
tests has been deprecated and will be removed in Django 1.10. Us
e
:func:`@override_settings(ROOT_URLCONF=...) <django.test.override_settings>`
instead.
``prefix`` argument to :func:`~django.conf.urls.i18n.i18n_patterns`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
docs/topics/testing/tools.txt
Dosyayı görüntüle @
1392aff4
...
...
@@ -639,7 +639,6 @@ functionality like:
* The ability to run tests with :ref:`modified settings <overriding-settings>`.
* Using the :attr:`~SimpleTestCase.client` :class:`~django.test.Client`.
* Custom test-time :attr:`URL maps <SimpleTestCase.urls>`.
If you need any of the other more complex and heavyweight Django-specific
features like:
...
...
@@ -1080,39 +1079,12 @@ using multiple databases and set :attr:`multi_db=True
URLconf configuration
~~~~~~~~~~~~~~~~~~~~~
.. attribute:: SimpleTestCase.urls
.. deprecated:: 1.8
Use ``@override_settings(ROOT_URLCONF=...)`` instead for URLconf
configuration.
If your application provides views, you may want to include tests that use the
test client to exercise those views. However, an end user is free to deploy the
views in your application at any URL of their choosing. This means that your
tests can't rely upon the fact that your views will be available at a
particular URL.
In order to provide a reliable URL space for your test,
``django.test.*TestCase`` classes provide the ability to customize the URLconf
configuration for the duration of the execution of a test suite. If your
``*TestCase`` instance defines an ``urls`` attribute, the ``*TestCase`` will use
the value of that attribute as the :setting:`ROOT_URLCONF` for the duration
of that test.
For example::
from django.test import TestCase
class TestMyViews(TestCase):
urls = 'myapp.test_urls'
def test_index_page_view(self):
# Here you'd test your view using ``Client``.
call_some_test_code()
This test case will use the contents of ``myapp.test_urls`` as the
URLconf for the duration of the test case.
particular URL. Decorate your test class or test method with
``@override_settings(ROOT_URLCONF=...)`` for URLconf configuration.
.. _emptying-test-outbox:
...
...
tests/deprecation/tests.py
Dosyayı görüntüle @
1392aff4
from
__future__
import
unicode_literals
import
os
import
unittest
import
warnings
from
django.test
import
SimpleTestCase
from
django.test.utils
import
reset_warning_registry
from
django.utils
import
six
from
django.utils.deprecation
import
RenameMethodsBase
from
django.utils.encoding
import
force_text
class
RenameManagerMethods
(
RenameMethodsBase
):
...
...
@@ -173,27 +170,3 @@ class RenameMethodsTests(SimpleTestCase):
'`DeprecatedMixin.old` is deprecated, use `new` instead.'
,
'`RenamedMixin.old` is deprecated, use `new` instead.'
,
])
class
DeprecatingSimpleTestCaseUrls
(
unittest
.
TestCase
):
def
test_deprecation
(
self
):
"""
Ensure the correct warning is raised when SimpleTestCase.urls is used.
"""
class
TempTestCase
(
SimpleTestCase
):
urls
=
'tests.urls'
def
test
(
self
):
pass
with
warnings
.
catch_warnings
(
record
=
True
)
as
recorded
:
warnings
.
filterwarnings
(
'always'
)
suite
=
unittest
.
TestLoader
()
.
loadTestsFromTestCase
(
TempTestCase
)
with
open
(
os
.
devnull
,
'w'
)
as
devnull
:
unittest
.
TextTestRunner
(
stream
=
devnull
,
verbosity
=
2
)
.
run
(
suite
)
msg
=
force_text
(
recorded
.
pop
()
.
message
)
self
.
assertEqual
(
msg
,
"SimpleTestCase.urls is deprecated and will be removed in "
"Django 1.10. Use @override_settings(ROOT_URLCONF=...) "
"in TempTestCase instead."
)
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