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
2f1394c7
Kaydet (Commit)
2f1394c7
authored
Şub 01, 2017
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added a test for force_text()'s DjangoUnicodeDecodeError path.
üst
8e3f9d3e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
test_encoding.py
tests/utils_tests/test_encoding.py
+12
-3
No files found.
tests/utils_tests/test_encoding.py
Dosyayı görüntüle @
2f1394c7
...
...
@@ -2,14 +2,15 @@ import datetime
import
unittest
from
urllib.parse
import
quote_plus
from
django.test
import
SimpleTestCase
from
django.utils.encoding
import
(
escape_uri_path
,
filepath_to_uri
,
force_bytes
,
force_text
,
iri_to_uri
,
smart_text
,
uri_to_iri
,
DjangoUnicodeDecodeError
,
escape_uri_path
,
filepath_to_uri
,
force_bytes
,
force_text
,
iri_to_uri
,
smart_text
,
uri_to_iri
,
)
from
django.utils.functional
import
SimpleLazyObject
class
TestEncodingUtils
(
unittest
.
TestCase
):
class
TestEncodingUtils
(
Simple
TestCase
):
def
test_force_text_exception
(
self
):
"""
Broken __str__ actually raises an error.
...
...
@@ -26,6 +27,14 @@ class TestEncodingUtils(unittest.TestCase):
s
=
SimpleLazyObject
(
lambda
:
'x'
)
self
.
assertTrue
(
type
(
force_text
(
s
)),
str
)
def
test_force_text_DjangoUnicodeDecodeError
(
self
):
msg
=
(
"'utf-8' codec can't decode byte 0xff in position 0: invalid "
"start byte. You passed in b'
\\
xff' (<class 'bytes'>)"
)
with
self
.
assertRaisesMessage
(
DjangoUnicodeDecodeError
,
msg
):
force_text
(
b
'
\xff
'
)
def
test_force_bytes_exception
(
self
):
"""
force_bytes knows how to convert to bytes an exception
...
...
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