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
f7c2e82d
Kaydet (Commit)
f7c2e82d
authored
Agu 15, 2012
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[py3] Fixed middleware tests.
Removed several inappropriate .encode('utf-8') calls in the process.
üst
2b157b0a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
tests.py
tests/regressiontests/middleware/tests.py
+8
-7
No files found.
tests/regressiontests/middleware/tests.py
Dosyayı görüntüle @
f7c2e82d
...
...
@@ -15,6 +15,7 @@ from django.middleware.http import ConditionalGetMiddleware
from
django.middleware.gzip
import
GZipMiddleware
from
django.test
import
TestCase
,
RequestFactory
from
django.test.utils
import
override_settings
from
django.utils
import
six
from
django.utils.six.moves
import
xrange
...
...
@@ -507,9 +508,9 @@ class GZipMiddlewareTest(TestCase):
"""
Tests the GZip middleware.
"""
short_string
=
"This string is too short to be worth compressing."
compressible_string
=
'a'
*
500
uncompressible_string
=
''
.
join
(
chr
(
random
.
randint
(
0
,
255
))
for
_
in
xrange
(
500
))
short_string
=
b
"This string is too short to be worth compressing."
compressible_string
=
b
'a'
*
500
uncompressible_string
=
b
''
.
join
(
six
.
int2byte
(
random
.
randint
(
0
,
255
))
for
_
in
xrange
(
500
))
def
setUp
(
self
):
self
.
req
=
HttpRequest
()
...
...
@@ -534,7 +535,7 @@ class GZipMiddlewareTest(TestCase):
Tests that compression is performed on responses with compressible content.
"""
r
=
GZipMiddleware
()
.
process_response
(
self
.
req
,
self
.
resp
)
self
.
assertEqual
(
self
.
decompress
(
r
.
content
),
self
.
compressible_string
.
encode
(
'utf-8'
)
)
self
.
assertEqual
(
self
.
decompress
(
r
.
content
),
self
.
compressible_string
)
self
.
assertEqual
(
r
.
get
(
'Content-Encoding'
),
'gzip'
)
self
.
assertEqual
(
r
.
get
(
'Content-Length'
),
str
(
len
(
r
.
content
)))
...
...
@@ -545,7 +546,7 @@ class GZipMiddlewareTest(TestCase):
"""
self
.
resp
.
status_code
=
404
r
=
GZipMiddleware
()
.
process_response
(
self
.
req
,
self
.
resp
)
self
.
assertEqual
(
self
.
decompress
(
r
.
content
),
self
.
compressible_string
.
encode
(
'utf-8'
)
)
self
.
assertEqual
(
self
.
decompress
(
r
.
content
),
self
.
compressible_string
)
self
.
assertEqual
(
r
.
get
(
'Content-Encoding'
),
'gzip'
)
def
test_no_compress_short_response
(
self
):
...
...
@@ -573,7 +574,7 @@ class GZipMiddlewareTest(TestCase):
self
.
req
.
META
[
'HTTP_USER_AGENT'
]
=
'Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)'
self
.
resp
[
'Content-Type'
]
=
'application/javascript; charset=UTF-8'
r
=
GZipMiddleware
()
.
process_response
(
self
.
req
,
self
.
resp
)
self
.
assertEqual
(
r
.
content
,
self
.
compressible_string
.
encode
(
'utf-8'
)
)
self
.
assertEqual
(
r
.
content
,
self
.
compressible_string
)
self
.
assertEqual
(
r
.
get
(
'Content-Encoding'
),
None
)
def
test_no_compress_uncompressible_response
(
self
):
...
...
@@ -591,7 +592,7 @@ class ETagGZipMiddlewareTest(TestCase):
"""
Tests if the ETag middleware behaves correctly with GZip middleware.
"""
compressible_string
=
'a'
*
500
compressible_string
=
b
'a'
*
500
def
setUp
(
self
):
self
.
rf
=
RequestFactory
()
...
...
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