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
2d899ce1
Kaydet (Commit)
2d899ce1
authored
Şub 04, 2017
tarafından
Tim Graham
Kaydeden (comit)
GitHub
Şub 04, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #23919 -- Removed a Python 2 code path in force_text().
Reverted the obsolete fix and tests for refs #12302.
üst
26619ad7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
16 additions
and
49 deletions
+16
-49
encoding.py
django/utils/encoding.py
+1
-10
__init__.py
tests/view_tests/__init__.py
+0
-8
template_exception.html
tests/view_tests/templates/debug/template_exception.html
+1
-1
debugtags.py
tests/view_tests/templatetags/debugtags.py
+2
-4
test_debug.py
tests/view_tests/tests/test_debug.py
+9
-16
urls.py
tests/view_tests/urls.py
+1
-2
views.py
tests/view_tests/views.py
+2
-8
No files found.
django/utils/encoding.py
Dosyayı görüntüle @
2d899ce1
...
...
@@ -66,16 +66,7 @@ def force_text(s, encoding='utf-8', strings_only=False, errors='strict'):
else
:
s
=
str
(
s
)
except
UnicodeDecodeError
as
e
:
if
not
isinstance
(
s
,
Exception
):
raise
DjangoUnicodeDecodeError
(
s
,
*
e
.
args
)
else
:
# If we get to here, the caller has passed in an Exception
# subclass populated with non-ASCII bytestring data without a
# working __str__() method. Try to handle this without raising a
# further exception by individually forcing the exception args
# to strings.
s
=
' '
.
join
(
force_text
(
arg
,
encoding
,
strings_only
,
errors
)
for
arg
in
s
)
raise
DjangoUnicodeDecodeError
(
s
,
*
e
.
args
)
return
s
...
...
tests/view_tests/__init__.py
Dosyayı görüntüle @
2d899ce1
class
BrokenException
(
Exception
):
pass
except_args
=
(
b
'Broken!'
,
# plain exception with ASCII text
'¡Broken!'
,
# non-ASCII unicode data
'¡Broken!'
.
encode
(
'utf-8'
),
# non-ASCII, utf-8 encoded bytestring
b
'
\xa1
Broken!'
,
)
# non-ASCII, latin1 bytestring
tests/view_tests/templates/debug/template_exception.html
Dosyayı görüntüle @
2d899ce1
{% load debugtags %}
{% go_boom
arg
%}
{% go_boom %}
tests/view_tests/templatetags/debugtags.py
Dosyayı görüntüle @
2d899ce1
from
django
import
template
from
..views
import
BrokenException
register
=
template
.
Library
()
@register.simple_tag
def
go_boom
(
arg
):
raise
BrokenException
(
arg
)
def
go_boom
():
raise
Exception
(
'boom'
)
tests/view_tests/tests/test_debug.py
Dosyayı görüntüle @
2d899ce1
...
...
@@ -21,7 +21,6 @@ from django.views.debug import (
cleanse_setting
,
technical_500_response
,
)
from
..
import
BrokenException
,
except_args
from
..views
import
(
custom_exception_reporter_filter_view
,
index_page
,
multivalue_dict_key_error
,
non_sensitive_view
,
paranoid_view
,
...
...
@@ -127,11 +126,6 @@ class DebugViewTests(LoggingCaptureMixin, SimpleTestCase):
self
.
assertContains
(
response
,
"Raised by:"
,
status_code
=
404
)
self
.
assertContains
(
response
,
"view_tests.views.Http404View"
,
status_code
=
404
)
def
test_view_exceptions
(
self
):
for
n
in
range
(
len
(
except_args
)):
with
self
.
assertRaises
(
BrokenException
):
self
.
client
.
get
(
reverse
(
'view_exception'
,
args
=
(
n
,)))
def
test_non_l10ned_numeric_ids
(
self
):
"""
Numeric IDs and fancy traceback context blocks line numbers shouldn't be localized.
...
...
@@ -150,16 +144,15 @@ class DebugViewTests(LoggingCaptureMixin, SimpleTestCase):
)
def
test_template_exceptions
(
self
):
for
n
in
range
(
len
(
except_args
)):
try
:
self
.
client
.
get
(
reverse
(
'template_exception'
,
args
=
(
n
,)))
except
Exception
:
raising_loc
=
inspect
.
trace
()[
-
1
][
-
2
][
0
]
.
strip
()
self
.
assertNotEqual
(
raising_loc
.
find
(
'raise BrokenException'
),
-
1
,
"Failed to find 'raise BrokenException' in last frame of "
"traceback, instead found:
%
s"
%
raising_loc
)
try
:
self
.
client
.
get
(
reverse
(
'template_exception'
))
except
Exception
:
raising_loc
=
inspect
.
trace
()[
-
1
][
-
2
][
0
]
.
strip
()
self
.
assertNotEqual
(
raising_loc
.
find
(
"raise Exception('boom')"
),
-
1
,
"Failed to find 'raise Exception' in last frame of "
"traceback, instead found:
%
s"
%
raising_loc
)
def
test_template_loader_postmortem
(
self
):
"""Tests for not existing file"""
...
...
tests/view_tests/urls.py
Dosyayı görüntüle @
2d899ce1
...
...
@@ -96,8 +96,7 @@ urlpatterns += i18n_patterns(
)
urlpatterns
+=
[
url
(
r'view_exception/(?P<n>[0-9]+)/$'
,
views
.
view_exception
,
name
=
'view_exception'
),
url
(
r'template_exception/(?P<n>[0-9]+)/$'
,
views
.
template_exception
,
name
=
'template_exception'
),
url
(
r'template_exception/$'
,
views
.
template_exception
,
name
=
'template_exception'
),
url
(
r'^raises_template_does_not_exist/(?P<path>.+)$'
,
views
.
raises_template_does_not_exist
,
...
...
tests/view_tests/views.py
Dosyayı görüntüle @
2d899ce1
...
...
@@ -16,8 +16,6 @@ from django.views.decorators.debug import (
sensitive_post_parameters
,
sensitive_variables
,
)
from
.
import
BrokenException
,
except_args
def
index_page
(
request
):
"""Dummy index page"""
...
...
@@ -70,12 +68,8 @@ class Http404View(View):
raise
Http404
(
"Testing class-based technical 404."
)
def
view_exception
(
request
,
n
):
raise
BrokenException
(
except_args
[
int
(
n
)])
def
template_exception
(
request
,
n
):
return
render
(
request
,
'debug/template_exception.html'
,
{
'arg'
:
except_args
[
int
(
n
)]})
def
template_exception
(
request
):
return
render
(
request
,
'debug/template_exception.html'
)
def
jsi18n
(
request
):
...
...
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