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
edf3b88f
Kaydet (Commit)
edf3b88f
authored
Ara 22, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #25969 -- Replaced usage of render_to_response() with render() in tests.
üst
312fc1af
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
20 deletions
+19
-20
views.py
tests/test_client/views.py
+5
-7
tests.py
tests/test_client_regress/tests.py
+5
-3
views.py
tests/test_client_regress/views.py
+4
-4
views.py
tests/view_tests/views.py
+5
-6
No files found.
tests/test_client/views.py
Dosyayı görüntüle @
edf3b88f
...
...
@@ -9,7 +9,7 @@ from django.http import (
HttpResponse
,
HttpResponseBadRequest
,
HttpResponseNotAllowed
,
HttpResponseNotFound
,
HttpResponseRedirect
,
)
from
django.shortcuts
import
render
_to_response
from
django.shortcuts
import
render
from
django.template
import
Context
,
Template
from
django.test
import
Client
from
django.utils.decorators
import
method_decorator
...
...
@@ -168,12 +168,10 @@ def form_view_with_template(request):
else
:
form
=
TestForm
()
message
=
'GET form page'
return
render_to_response
(
'form_view.html'
,
{
'form'
:
form
,
'message'
:
message
}
)
return
render
(
request
,
'form_view.html'
,
{
'form'
:
form
,
'message'
:
message
,
})
class
BaseTestFormSet
(
BaseFormSet
):
...
...
tests/test_client_regress/tests.py
Dosyayı görüntüle @
edf3b88f
...
...
@@ -12,7 +12,9 @@ from django.contrib.auth.models import User
from
django.contrib.auth.signals
import
user_logged_in
,
user_logged_out
from
django.core.urlresolvers
import
NoReverseMatch
,
reverse
from
django.http
import
HttpResponse
from
django.template
import
Context
,
TemplateSyntaxError
,
engines
from
django.template
import
(
Context
,
RequestContext
,
TemplateSyntaxError
,
engines
,
)
from
django.template.response
import
SimpleTemplateResponse
from
django.test
import
(
Client
,
SimpleTestCase
,
TestCase
,
ignore_warnings
,
override_settings
,
...
...
@@ -1021,7 +1023,7 @@ class ContextTests(TestDataMixin, TestCase):
def
test_single_context
(
self
):
"Context variables can be retrieved from a single context"
response
=
self
.
client
.
get
(
"/request_data/"
,
data
=
{
'foo'
:
'whiz'
})
self
.
assert
Equal
(
response
.
context
.
__class__
,
Context
)
self
.
assert
IsInstance
(
response
.
context
,
Request
Context
)
self
.
assertIn
(
'get-foo'
,
response
.
context
)
self
.
assertEqual
(
response
.
context
[
'get-foo'
],
'whiz'
)
self
.
assertEqual
(
response
.
context
[
'data'
],
'sausage'
)
...
...
@@ -1083,7 +1085,7 @@ class ContextTests(TestDataMixin, TestCase):
response.context is not lost when view call another view.
"""
response
=
self
.
client
.
get
(
"/nested_view/"
)
self
.
assert
Equal
(
response
.
context
.
__class__
,
Context
)
self
.
assert
IsInstance
(
response
.
context
,
Request
Context
)
self
.
assertEqual
(
response
.
context
[
'nested'
],
'yes'
)
...
...
tests/test_client_regress/views.py
Dosyayı görüntüle @
edf3b88f
...
...
@@ -4,7 +4,7 @@ from django.conf import settings
from
django.contrib.auth.decorators
import
login_required
from
django.core.serializers.json
import
DjangoJSONEncoder
from
django.http
import
HttpResponse
,
HttpResponseRedirect
,
JsonResponse
from
django.shortcuts
import
render
,
render_to_response
from
django.shortcuts
import
render
from
django.template.loader
import
render_to_string
from
django.test
import
Client
from
django.test.client
import
CONTENT_TYPE_RE
...
...
@@ -37,7 +37,7 @@ get_view = login_required(get_view)
def
request_data
(
request
,
template
=
'base.html'
,
data
=
'sausage'
):
"A simple view that returns the request data in the context"
return
render
_to_response
(
template
,
{
return
render
(
request
,
template
,
{
'get-foo'
:
request
.
GET
.
get
(
'foo'
),
'get-bar'
:
request
.
GET
.
get
(
'bar'
),
'post-foo'
:
request
.
POST
.
get
(
'foo'
),
...
...
@@ -66,7 +66,7 @@ def nested_view(request):
setup_test_environment
()
c
=
Client
()
c
.
get
(
"/no_template_view/"
)
return
render
_to_response
(
'base.html'
,
{
'nested'
:
'yes'
})
return
render
(
request
,
'base.html'
,
{
'nested'
:
'yes'
})
def
login_protected_redirect_view
(
request
):
...
...
@@ -98,7 +98,7 @@ def request_methods_view(request):
def
return_unicode
(
request
):
return
render
_to_response
(
'unicode.html'
)
return
render
(
request
,
'unicode.html'
)
def
return_undecodable_binary
(
request
):
...
...
tests/view_tests/views.py
Dosyayı görüntüle @
edf3b88f
...
...
@@ -8,7 +8,7 @@ import sys
from
django.core.exceptions
import
PermissionDenied
,
SuspiciousOperation
from
django.core.urlresolvers
import
get_resolver
from
django.http
import
Http404
,
HttpResponse
,
JsonResponse
from
django.shortcuts
import
render
,
render_to_response
from
django.shortcuts
import
render
from
django.template
import
TemplateDoesNotExist
from
django.views.debug
import
(
SafeExceptionReporterFilter
,
technical_500_response
,
...
...
@@ -74,23 +74,22 @@ def view_exception(request, n):
def
template_exception
(
request
,
n
):
return
render_to_response
(
'debug/template_exception.html'
,
{
'arg'
:
except_args
[
int
(
n
)]})
return
render
(
request
,
'debug/template_exception.html'
,
{
'arg'
:
except_args
[
int
(
n
)]})
def
jsi18n
(
request
):
return
render
_to_response
(
'jsi18n.html'
)
return
render
(
request
,
'jsi18n.html'
)
def
jsi18n_multi_catalogs
(
request
):
return
render
_to_response
(
'jsi18n-multi-catalogs.html'
)
return
render
(
render
,
'jsi18n-multi-catalogs.html'
)
def
raises_template_does_not_exist
(
request
,
path
=
'i_dont_exist.html'
):
# We need to inspect the HTML generated by the fancy 500 debug view but
# the test client ignores it, so we send it explicitly.
try
:
return
render
_to_response
(
path
)
return
render
(
request
,
path
)
except
TemplateDoesNotExist
:
return
technical_500_response
(
request
,
*
sys
.
exc_info
())
...
...
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