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
fa75b2cb
Unverified
Kaydet (Commit)
fa75b2cb
authored
Şub 07, 2018
tarafından
Tim Graham
Kaydeden (comit)
GitHub
Şub 07, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #27795 -- Removed force_bytes/text() usage in tests.
üst
b38532cd
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
29 additions
and
39 deletions
+29
-39
test_logentry.py
tests/admin_utils/test_logentry.py
+3
-3
tests.py
tests/admin_views/tests.py
+13
-15
test_hashers.py
tests/auth_tests/test_hashers.py
+1
-2
test_templates.py
tests/auth_tests/test_templates.py
+1
-2
test_views.py
tests/auth_tests/test_views.py
+1
-2
tests.py
tests/file_uploads/tests.py
+2
-3
views.py
tests/file_uploads/views.py
+2
-3
test_geos.py
tests/gis_tests/geos_tests/test_geos.py
+1
-2
tests.py
tests/mail/tests.py
+4
-5
test_debug.py
tests/view_tests/tests/test_debug.py
+1
-2
No files found.
tests/admin_utils/test_logentry.py
Dosyayı görüntüle @
fa75b2cb
...
@@ -8,7 +8,6 @@ from django.contrib.contenttypes.models import ContentType
...
@@ -8,7 +8,6 @@ from django.contrib.contenttypes.models import ContentType
from
django.test
import
TestCase
,
override_settings
from
django.test
import
TestCase
,
override_settings
from
django.urls
import
reverse
from
django.urls
import
reverse
from
django.utils
import
translation
from
django.utils
import
translation
from
django.utils.encoding
import
force_bytes
from
django.utils.html
import
escape
from
django.utils.html
import
escape
from
.models
import
Article
,
ArticleProxy
,
Site
from
.models
import
Article
,
ArticleProxy
,
Site
...
@@ -211,9 +210,10 @@ class LogEntryTests(TestCase):
...
@@ -211,9 +210,10 @@ class LogEntryTests(TestCase):
logentry
.
content_type
=
None
logentry
.
content_type
=
None
logentry
.
save
()
logentry
.
save
()
counted_presence_before
=
response
.
content
.
count
(
force_bytes
(
should_contain
))
should_contain
=
should_contain
.
encode
()
counted_presence_before
=
response
.
content
.
count
(
should_contain
)
response
=
self
.
client
.
get
(
reverse
(
'admin:index'
))
response
=
self
.
client
.
get
(
reverse
(
'admin:index'
))
counted_presence_after
=
response
.
content
.
count
(
force_bytes
(
should_contain
)
)
counted_presence_after
=
response
.
content
.
count
(
should_contain
)
self
.
assertEqual
(
counted_presence_before
-
1
,
counted_presence_after
)
self
.
assertEqual
(
counted_presence_before
-
1
,
counted_presence_after
)
def
test_proxy_model_content_type_is_used_for_log_entries
(
self
):
def
test_proxy_model_content_type_is_used_for_log_entries
(
self
):
...
...
tests/admin_views/tests.py
Dosyayı görüntüle @
fa75b2cb
...
@@ -29,7 +29,7 @@ from django.test.utils import override_script_prefix, patch_logger
...
@@ -29,7 +29,7 @@ from django.test.utils import override_script_prefix, patch_logger
from
django.urls
import
NoReverseMatch
,
resolve
,
reverse
from
django.urls
import
NoReverseMatch
,
resolve
,
reverse
from
django.utils
import
formats
,
translation
from
django.utils
import
formats
,
translation
from
django.utils.cache
import
get_max_age
from
django.utils.cache
import
get_max_age
from
django.utils.encoding
import
force_bytes
,
force_text
,
iri_to_uri
from
django.utils.encoding
import
iri_to_uri
from
django.utils.html
import
escape
from
django.utils.html
import
escape
from
django.utils.http
import
urlencode
from
django.utils.http
import
urlencode
...
@@ -183,8 +183,8 @@ class AdminViewBasicTestCase(TestCase):
...
@@ -183,8 +183,8 @@ class AdminViewBasicTestCase(TestCase):
"""
"""
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertLess
(
self
.
assertLess
(
response
.
content
.
index
(
force_bytes
(
text1
)),
response
.
content
.
index
(
text1
.
encode
(
)),
response
.
content
.
index
(
force_bytes
(
text2
)),
response
.
content
.
index
(
text2
.
encode
(
)),
(
failing_msg
or
''
)
+
'
\n
Response:
\n
'
+
response
.
content
.
decode
(
response
.
charset
)
(
failing_msg
or
''
)
+
'
\n
Response:
\n
'
+
response
.
content
.
decode
(
response
.
charset
)
)
)
...
@@ -2161,16 +2161,14 @@ class AdminViewDeletedObjectsTest(TestCase):
...
@@ -2161,16 +2161,14 @@ class AdminViewDeletedObjectsTest(TestCase):
cause them to be scheduled for deletion.
cause them to be scheduled for deletion.
"""
"""
pattern
=
re
.
compile
(
pattern
=
re
.
compile
(
force_bytes
(
r'<li>Plot: <a href="
%
s">World Domination</a>\s*<ul>\s*'
r'<li>Plot: <a href="
%
s">World Domination</a>\s*<ul>\s*'
r'<li>Plot details: <a href="
%
s">almost finished</a>'
%
(
r'<li>Plot details: <a href="
%
s">almost finished</a>'
%
(
reverse
(
'admin:admin_views_plot_change'
,
args
=
(
self
.
pl1
.
pk
,)),
reverse
(
'admin:admin_views_plot_change'
,
args
=
(
self
.
pl1
.
pk
,)),
reverse
(
'admin:admin_views_plotdetails_change'
,
args
=
(
self
.
pd1
.
pk
,)),
reverse
(
'admin:admin_views_plotdetails_change'
,
args
=
(
self
.
pd1
.
pk
,)),
)
)
)
)
)
response
=
self
.
client
.
get
(
reverse
(
'admin:admin_views_villain_delete'
,
args
=
(
self
.
v1
.
pk
,)))
response
=
self
.
client
.
get
(
reverse
(
'admin:admin_views_villain_delete'
,
args
=
(
self
.
v1
.
pk
,)))
self
.
assertRegex
(
response
.
content
,
pattern
)
self
.
assertRegex
(
response
.
content
.
decode
()
,
pattern
)
def
test_cyclic
(
self
):
def
test_cyclic
(
self
):
"""
"""
...
@@ -5455,7 +5453,7 @@ class AdminKeepChangeListFiltersTests(TestCase):
...
@@ -5455,7 +5453,7 @@ class AdminKeepChangeListFiltersTests(TestCase):
# Check the `change_view` link has the correct querystring.
# Check the `change_view` link has the correct querystring.
detail_link
=
re
.
search
(
detail_link
=
re
.
search
(
'<a href="(.*?)">{}</a>'
.
format
(
self
.
joepublicuser
.
username
),
'<a href="(.*?)">{}</a>'
.
format
(
self
.
joepublicuser
.
username
),
force_text
(
response
.
content
)
response
.
content
.
decode
(
)
)
)
self
.
assertURLEqual
(
detail_link
.
group
(
1
),
self
.
get_change_url
())
self
.
assertURLEqual
(
detail_link
.
group
(
1
),
self
.
get_change_url
())
...
@@ -5467,21 +5465,21 @@ class AdminKeepChangeListFiltersTests(TestCase):
...
@@ -5467,21 +5465,21 @@ class AdminKeepChangeListFiltersTests(TestCase):
# Check the form action.
# Check the form action.
form_action
=
re
.
search
(
form_action
=
re
.
search
(
'<form action="(.*?)" method="post" id="user_form".*?>'
,
'<form action="(.*?)" method="post" id="user_form".*?>'
,
force_text
(
response
.
content
)
response
.
content
.
decode
(
)
)
)
self
.
assertURLEqual
(
form_action
.
group
(
1
),
'?
%
s'
%
self
.
get_preserved_filters_querystring
())
self
.
assertURLEqual
(
form_action
.
group
(
1
),
'?
%
s'
%
self
.
get_preserved_filters_querystring
())
# Check the history link.
# Check the history link.
history_link
=
re
.
search
(
history_link
=
re
.
search
(
'<a href="(.*?)" class="historylink">History</a>'
,
'<a href="(.*?)" class="historylink">History</a>'
,
force_text
(
response
.
content
)
response
.
content
.
decode
(
)
)
)
self
.
assertURLEqual
(
history_link
.
group
(
1
),
self
.
get_history_url
())
self
.
assertURLEqual
(
history_link
.
group
(
1
),
self
.
get_history_url
())
# Check the delete link.
# Check the delete link.
delete_link
=
re
.
search
(
delete_link
=
re
.
search
(
'<a href="(.*?)" class="deletelink">Delete</a>'
,
'<a href="(.*?)" class="deletelink">Delete</a>'
,
force_text
(
response
.
content
)
response
.
content
.
decode
(
)
)
)
self
.
assertURLEqual
(
delete_link
.
group
(
1
),
self
.
get_delete_url
())
self
.
assertURLEqual
(
delete_link
.
group
(
1
),
self
.
get_delete_url
())
...
@@ -5531,7 +5529,7 @@ class AdminKeepChangeListFiltersTests(TestCase):
...
@@ -5531,7 +5529,7 @@ class AdminKeepChangeListFiltersTests(TestCase):
# Check the form action.
# Check the form action.
form_action
=
re
.
search
(
form_action
=
re
.
search
(
'<form action="(.*?)" method="post" id="user_form".*?>'
,
'<form action="(.*?)" method="post" id="user_form".*?>'
,
force_text
(
response
.
content
)
response
.
content
.
decode
(
)
)
)
self
.
assertURLEqual
(
form_action
.
group
(
1
),
'?
%
s'
%
self
.
get_preserved_filters_querystring
())
self
.
assertURLEqual
(
form_action
.
group
(
1
),
'?
%
s'
%
self
.
get_preserved_filters_querystring
())
...
...
tests/auth_tests/test_hashers.py
Dosyayı görüntüle @
fa75b2cb
...
@@ -9,7 +9,6 @@ from django.contrib.auth.hashers import (
...
@@ -9,7 +9,6 @@ from django.contrib.auth.hashers import (
)
)
from
django.test
import
SimpleTestCase
from
django.test
import
SimpleTestCase
from
django.test.utils
import
override_settings
from
django.test.utils
import
override_settings
from
django.utils.encoding
import
force_bytes
try
:
try
:
import
crypt
import
crypt
...
@@ -238,7 +237,7 @@ class TestUtilsHashPass(SimpleTestCase):
...
@@ -238,7 +237,7 @@ class TestUtilsHashPass(SimpleTestCase):
# Get the original salt (includes the original workload factor)
# Get the original salt (includes the original workload factor)
algorithm
,
data
=
encoded
.
split
(
'$'
,
1
)
algorithm
,
data
=
encoded
.
split
(
'$'
,
1
)
expected_call
=
((
'wrong_password'
,
force_bytes
(
data
[:
29
]
)),)
expected_call
=
((
'wrong_password'
,
data
[:
29
]
.
encode
(
)),)
self
.
assertEqual
(
hasher
.
encode
.
call_args_list
,
[
expected_call
]
*
3
)
self
.
assertEqual
(
hasher
.
encode
.
call_args_list
,
[
expected_call
]
*
3
)
def
test_unusable
(
self
):
def
test_unusable
(
self
):
...
...
tests/auth_tests/test_templates.py
Dosyayı görüntüle @
fa75b2cb
...
@@ -7,7 +7,6 @@ from django.contrib.auth.views import (
...
@@ -7,7 +7,6 @@ from django.contrib.auth.views import (
)
)
from
django.test
import
RequestFactory
,
TestCase
,
override_settings
from
django.test
import
RequestFactory
,
TestCase
,
override_settings
from
django.urls
import
reverse
from
django.urls
import
reverse
from
django.utils.encoding
import
force_bytes
from
django.utils.http
import
urlsafe_base64_encode
from
django.utils.http
import
urlsafe_base64_encode
from
.client
import
PasswordResetConfirmClient
from
.client
import
PasswordResetConfirmClient
...
@@ -48,7 +47,7 @@ class AuthTemplateTests(TestCase):
...
@@ -48,7 +47,7 @@ class AuthTemplateTests(TestCase):
client
=
PasswordResetConfirmClient
()
client
=
PasswordResetConfirmClient
()
default_token_generator
=
PasswordResetTokenGenerator
()
default_token_generator
=
PasswordResetTokenGenerator
()
token
=
default_token_generator
.
make_token
(
self
.
user
)
token
=
default_token_generator
.
make_token
(
self
.
user
)
uidb64
=
urlsafe_base64_encode
(
force_bytes
(
self
.
user
.
pk
))
.
decode
()
uidb64
=
urlsafe_base64_encode
(
str
(
self
.
user
.
pk
)
.
encode
(
))
.
decode
()
url
=
reverse
(
'password_reset_confirm'
,
kwargs
=
{
'uidb64'
:
uidb64
,
'token'
:
token
})
url
=
reverse
(
'password_reset_confirm'
,
kwargs
=
{
'uidb64'
:
uidb64
,
'token'
:
token
})
response
=
client
.
get
(
url
)
response
=
client
.
get
(
url
)
self
.
assertContains
(
response
,
'<title>Enter new password</title>'
)
self
.
assertContains
(
response
,
'<title>Enter new password</title>'
)
...
...
tests/auth_tests/test_views.py
Dosyayı görüntüle @
fa75b2cb
...
@@ -28,7 +28,6 @@ from django.middleware.csrf import CsrfViewMiddleware, get_token
...
@@ -28,7 +28,6 @@ from django.middleware.csrf import CsrfViewMiddleware, get_token
from
django.test
import
Client
,
TestCase
,
override_settings
from
django.test
import
Client
,
TestCase
,
override_settings
from
django.test.utils
import
patch_logger
from
django.test.utils
import
patch_logger
from
django.urls
import
NoReverseMatch
,
reverse
,
reverse_lazy
from
django.urls
import
NoReverseMatch
,
reverse
,
reverse_lazy
from
django.utils.encoding
import
force_text
from
django.utils.translation
import
LANGUAGE_SESSION_KEY
from
django.utils.translation
import
LANGUAGE_SESSION_KEY
from
.client
import
PasswordResetConfirmClient
from
.client
import
PasswordResetConfirmClient
...
@@ -1150,7 +1149,7 @@ class ChangelistTests(AuthViewsTestCase):
...
@@ -1150,7 +1149,7 @@ class ChangelistTests(AuthViewsTestCase):
# Test the link inside password field help_text.
# Test the link inside password field help_text.
rel_link
=
re
.
search
(
rel_link
=
re
.
search
(
r'you can change the password using <a href="([^"]*)">this form</a>'
,
r'you can change the password using <a href="([^"]*)">this form</a>'
,
force_text
(
response
.
content
)
response
.
content
.
decode
(
)
)
.
groups
()[
0
]
)
.
groups
()[
0
]
self
.
assertEqual
(
self
.
assertEqual
(
os
.
path
.
normpath
(
user_change_url
+
rel_link
),
os
.
path
.
normpath
(
user_change_url
+
rel_link
),
...
...
tests/file_uploads/tests.py
Dosyayı görüntüle @
fa75b2cb
...
@@ -12,7 +12,6 @@ from django.core.files import temp as tempfile
...
@@ -12,7 +12,6 @@ from django.core.files import temp as tempfile
from
django.core.files.uploadedfile
import
SimpleUploadedFile
from
django.core.files.uploadedfile
import
SimpleUploadedFile
from
django.http.multipartparser
import
MultiPartParser
,
parse_header
from
django.http.multipartparser
import
MultiPartParser
,
parse_header
from
django.test
import
SimpleTestCase
,
TestCase
,
client
,
override_settings
from
django.test
import
SimpleTestCase
,
TestCase
,
client
,
override_settings
from
django.utils.encoding
import
force_bytes
from
.
import
uploadhandler
from
.
import
uploadhandler
from
.models
import
FileModel
from
.models
import
FileModel
...
@@ -65,7 +64,7 @@ class FileUploadTests(TestCase):
...
@@ -65,7 +64,7 @@ class FileUploadTests(TestCase):
post_data
[
key
+
'_hash'
]
=
hashlib
.
sha1
(
post_data
[
key
]
.
read
())
.
hexdigest
()
post_data
[
key
+
'_hash'
]
=
hashlib
.
sha1
(
post_data
[
key
]
.
read
())
.
hexdigest
()
post_data
[
key
]
.
seek
(
0
)
post_data
[
key
]
.
seek
(
0
)
except
AttributeError
:
except
AttributeError
:
post_data
[
key
+
'_hash'
]
=
hashlib
.
sha1
(
force_bytes
(
post_data
[
key
]
))
.
hexdigest
()
post_data
[
key
+
'_hash'
]
=
hashlib
.
sha1
(
post_data
[
key
]
.
encode
(
))
.
hexdigest
()
response
=
self
.
client
.
post
(
'/verify/'
,
post_data
)
response
=
self
.
client
.
post
(
'/verify/'
,
post_data
)
...
@@ -78,7 +77,7 @@ class FileUploadTests(TestCase):
...
@@ -78,7 +77,7 @@ class FileUploadTests(TestCase):
'Content-Type: application/octet-stream'
,
'Content-Type: application/octet-stream'
,
'Content-Transfer-Encoding: base64'
,
'Content-Transfer-Encoding: base64'
,
''
]))
''
]))
payload
.
write
(
b
"
\r\n
"
+
encode
(
force_bytes
(
content
))
+
b
"
\r\n
"
)
payload
.
write
(
b
'
\r\n
'
+
encode
(
content
.
encode
())
+
b
'
\r\n
'
)
payload
.
write
(
'--'
+
client
.
BOUNDARY
+
'--
\r\n
'
)
payload
.
write
(
'--'
+
client
.
BOUNDARY
+
'--
\r\n
'
)
r
=
{
r
=
{
'CONTENT_LENGTH'
:
len
(
payload
),
'CONTENT_LENGTH'
:
len
(
payload
),
...
...
tests/file_uploads/views.py
Dosyayı görüntüle @
fa75b2cb
...
@@ -3,7 +3,6 @@ import os
...
@@ -3,7 +3,6 @@ import os
from
django.core.files.uploadedfile
import
UploadedFile
from
django.core.files.uploadedfile
import
UploadedFile
from
django.http
import
HttpResponse
,
HttpResponseServerError
,
JsonResponse
from
django.http
import
HttpResponse
,
HttpResponseServerError
,
JsonResponse
from
django.utils.encoding
import
force_bytes
,
force_text
from
.models
import
FileModel
from
.models
import
FileModel
from
.tests
import
UNICODE_FILENAME
,
UPLOAD_TO
from
.tests
import
UNICODE_FILENAME
,
UPLOAD_TO
...
@@ -42,7 +41,7 @@ def file_upload_view_verify(request):
...
@@ -42,7 +41,7 @@ def file_upload_view_verify(request):
if
isinstance
(
value
,
UploadedFile
):
if
isinstance
(
value
,
UploadedFile
):
new_hash
=
hashlib
.
sha1
(
value
.
read
())
.
hexdigest
()
new_hash
=
hashlib
.
sha1
(
value
.
read
())
.
hexdigest
()
else
:
else
:
new_hash
=
hashlib
.
sha1
(
force_bytes
(
value
))
.
hexdigest
()
new_hash
=
hashlib
.
sha1
(
value
.
encode
(
))
.
hexdigest
()
if
new_hash
!=
submitted_hash
:
if
new_hash
!=
submitted_hash
:
return
HttpResponseServerError
()
return
HttpResponseServerError
()
...
@@ -151,7 +150,7 @@ def file_upload_content_type_extra(request):
...
@@ -151,7 +150,7 @@ def file_upload_content_type_extra(request):
"""
"""
params
=
{}
params
=
{}
for
file_name
,
uploadedfile
in
request
.
FILES
.
items
():
for
file_name
,
uploadedfile
in
request
.
FILES
.
items
():
params
[
file_name
]
=
{
k
:
force_text
(
v
)
for
k
,
v
in
uploadedfile
.
content_type_extra
.
items
()}
params
[
file_name
]
=
{
k
:
v
.
decode
(
)
for
k
,
v
in
uploadedfile
.
content_type_extra
.
items
()}
return
JsonResponse
(
params
)
return
JsonResponse
(
params
)
...
...
tests/gis_tests/geos_tests/test_geos.py
Dosyayı görüntüle @
fa75b2cb
...
@@ -17,7 +17,6 @@ from django.contrib.gis.shortcuts import numpy
...
@@ -17,7 +17,6 @@ from django.contrib.gis.shortcuts import numpy
from
django.template
import
Context
from
django.template
import
Context
from
django.template.engine
import
Engine
from
django.template.engine
import
Engine
from
django.test
import
SimpleTestCase
from
django.test
import
SimpleTestCase
from
django.utils.encoding
import
force_bytes
from
..test_data
import
TestDataMixin
from
..test_data
import
TestDataMixin
...
@@ -160,7 +159,7 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
...
@@ -160,7 +159,7 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
ref_pnt
=
GEOSGeometry
(
'POINT(5 23)'
)
ref_pnt
=
GEOSGeometry
(
'POINT(5 23)'
)
wkt_f
=
BytesIO
()
wkt_f
=
BytesIO
()
wkt_f
.
write
(
force_bytes
(
ref_pnt
.
wkt
))
wkt_f
.
write
(
ref_pnt
.
wkt
.
encode
(
))
wkb_f
=
BytesIO
()
wkb_f
=
BytesIO
()
wkb_f
.
write
(
bytes
(
ref_pnt
.
wkb
))
wkb_f
.
write
(
bytes
(
ref_pnt
.
wkb
))
...
...
tests/mail/tests.py
Dosyayı görüntüle @
fa75b2cb
...
@@ -25,7 +25,6 @@ from django.core.mail.backends import console, dummy, filebased, locmem, smtp
...
@@ -25,7 +25,6 @@ from django.core.mail.backends import console, dummy, filebased, locmem, smtp
from
django.core.mail.message
import
BadHeaderError
,
sanitize_address
from
django.core.mail.message
import
BadHeaderError
,
sanitize_address
from
django.test
import
SimpleTestCase
,
override_settings
from
django.test
import
SimpleTestCase
,
override_settings
from
django.test.utils
import
requires_tz_support
from
django.test.utils
import
requires_tz_support
from
django.utils.encoding
import
force_bytes
,
force_text
from
django.utils.translation
import
gettext_lazy
from
django.utils.translation
import
gettext_lazy
...
@@ -800,7 +799,7 @@ class BaseEmailBackendTests(HeadersCheckMixin):
...
@@ -800,7 +799,7 @@ class BaseEmailBackendTests(HeadersCheckMixin):
self
.
assertEqual
(
num_sent
,
1
)
self
.
assertEqual
(
num_sent
,
1
)
message
=
self
.
get_the_message
()
message
=
self
.
get_the_message
()
self
.
assertEqual
(
message
[
"subject"
],
'=?utf-8?q?Ch=C3=A8re_maman?='
)
self
.
assertEqual
(
message
[
"subject"
],
'=?utf-8?q?Ch=C3=A8re_maman?='
)
self
.
assertEqual
(
force_text
(
message
.
get_payload
(
decode
=
True
)
),
'Je t
\'
aime très fort'
)
self
.
assertEqual
(
message
.
get_payload
(
decode
=
True
)
.
decode
(
),
'Je t
\'
aime très fort'
)
def
test_send_long_lines
(
self
):
def
test_send_long_lines
(
self
):
"""
"""
...
@@ -1083,7 +1082,7 @@ class FileBackendTests(BaseEmailBackendTests, SimpleTestCase):
...
@@ -1083,7 +1082,7 @@ class FileBackendTests(BaseEmailBackendTests, SimpleTestCase):
messages
=
[]
messages
=
[]
for
filename
in
os
.
listdir
(
self
.
tmp_dir
):
for
filename
in
os
.
listdir
(
self
.
tmp_dir
):
with
open
(
os
.
path
.
join
(
self
.
tmp_dir
,
filename
),
'rb'
)
as
fp
:
with
open
(
os
.
path
.
join
(
self
.
tmp_dir
,
filename
),
'rb'
)
as
fp
:
session
=
fp
.
read
()
.
split
(
force_bytes
(
'
\n
'
+
(
'-'
*
79
)
+
'
\n
'
,
encoding
=
'ascii'
)
)
session
=
fp
.
read
()
.
split
(
b
'
\n
'
+
(
b
'-'
*
79
)
+
b
'
\n
'
)
messages
.
extend
(
message_from_bytes
(
m
)
for
m
in
session
if
m
)
messages
.
extend
(
message_from_bytes
(
m
)
for
m
in
session
if
m
)
return
messages
return
messages
...
@@ -1140,7 +1139,7 @@ class ConsoleBackendTests(BaseEmailBackendTests, SimpleTestCase):
...
@@ -1140,7 +1139,7 @@ class ConsoleBackendTests(BaseEmailBackendTests, SimpleTestCase):
def
get_mailbox_content
(
self
):
def
get_mailbox_content
(
self
):
messages
=
self
.
stream
.
getvalue
()
.
split
(
'
\n
'
+
(
'-'
*
79
)
+
'
\n
'
)
messages
=
self
.
stream
.
getvalue
()
.
split
(
'
\n
'
+
(
'-'
*
79
)
+
'
\n
'
)
return
[
message_from_bytes
(
force_bytes
(
m
))
for
m
in
messages
if
m
]
return
[
message_from_bytes
(
str
(
m
)
.
encode
(
))
for
m
in
messages
if
m
]
def
test_console_stream_kwarg
(
self
):
def
test_console_stream_kwarg
(
self
):
"""
"""
...
@@ -1149,7 +1148,7 @@ class ConsoleBackendTests(BaseEmailBackendTests, SimpleTestCase):
...
@@ -1149,7 +1148,7 @@ class ConsoleBackendTests(BaseEmailBackendTests, SimpleTestCase):
s
=
StringIO
()
s
=
StringIO
()
connection
=
mail
.
get_connection
(
'django.core.mail.backends.console.EmailBackend'
,
stream
=
s
)
connection
=
mail
.
get_connection
(
'django.core.mail.backends.console.EmailBackend'
,
stream
=
s
)
send_mail
(
'Subject'
,
'Content'
,
'from@example.com'
,
[
'to@example.com'
],
connection
=
connection
)
send_mail
(
'Subject'
,
'Content'
,
'from@example.com'
,
[
'to@example.com'
],
connection
=
connection
)
message
=
force_bytes
(
s
.
getvalue
()
.
split
(
'
\n
'
+
(
'-'
*
79
)
+
'
\n
'
)[
0
]
)
message
=
str
(
s
.
getvalue
()
.
split
(
'
\n
'
+
(
'-'
*
79
)
+
'
\n
'
)[
0
])
.
encode
(
)
self
.
assertMessageHasHeaders
(
message
,
{
self
.
assertMessageHasHeaders
(
message
,
{
(
'MIME-Version'
,
'1.0'
),
(
'MIME-Version'
,
'1.0'
),
(
'Content-Type'
,
'text/plain; charset="utf-8"'
),
(
'Content-Type'
,
'text/plain; charset="utf-8"'
),
...
...
tests/view_tests/tests/test_debug.py
Dosyayı görüntüle @
fa75b2cb
...
@@ -16,7 +16,6 @@ from django.template import TemplateDoesNotExist
...
@@ -16,7 +16,6 @@ from django.template import TemplateDoesNotExist
from
django.test
import
RequestFactory
,
SimpleTestCase
,
override_settings
from
django.test
import
RequestFactory
,
SimpleTestCase
,
override_settings
from
django.test.utils
import
LoggingCaptureMixin
,
patch_logger
from
django.test.utils
import
LoggingCaptureMixin
,
patch_logger
from
django.urls
import
reverse
from
django.urls
import
reverse
from
django.utils.encoding
import
force_bytes
from
django.utils.functional
import
SimpleLazyObject
from
django.utils.functional
import
SimpleLazyObject
from
django.utils.safestring
import
mark_safe
from
django.utils.safestring
import
mark_safe
from
django.utils.version
import
PY36
from
django.utils.version
import
PY36
...
@@ -325,7 +324,7 @@ class ExceptionReporterTests(SimpleTestCase):
...
@@ -325,7 +324,7 @@ class ExceptionReporterTests(SimpleTestCase):
for
newline
in
[
'
\n
'
,
'
\r\n
'
,
'
\r
'
]:
for
newline
in
[
'
\n
'
,
'
\r\n
'
,
'
\r
'
]:
fd
,
filename
=
tempfile
.
mkstemp
(
text
=
False
)
fd
,
filename
=
tempfile
.
mkstemp
(
text
=
False
)
os
.
write
(
fd
,
force_bytes
(
newline
.
join
(
LINES
)
+
newline
))
os
.
write
(
fd
,
(
newline
.
join
(
LINES
)
+
newline
)
.
encode
(
))
os
.
close
(
fd
)
os
.
close
(
fd
)
try
:
try
:
...
...
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