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
e7b9c11c
Kaydet (Commit)
e7b9c11c
authored
Nis 10, 2013
tarafından
Baptiste Mispelon
Kaydeden (comit)
Claude Paroz
Nis 10, 2013
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #20231 -- Don't use allow_lazy on smart_split
üst
118faa08
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
36 deletions
+35
-36
text.py
django/utils/text.py
+0
-1
tests.py
tests/text/tests.py
+35
-35
No files found.
django/utils/text.py
Dosyayı görüntüle @
e7b9c11c
...
@@ -356,7 +356,6 @@ def smart_split(text):
...
@@ -356,7 +356,6 @@ def smart_split(text):
text
=
force_text
(
text
)
text
=
force_text
(
text
)
for
bit
in
smart_split_re
.
finditer
(
text
):
for
bit
in
smart_split_re
.
finditer
(
text
):
yield
bit
.
group
(
0
)
yield
bit
.
group
(
0
)
smart_split
=
allow_lazy
(
smart_split
,
six
.
text_type
)
def
_replace_entity
(
match
):
def
_replace_entity
(
match
):
text
=
match
.
group
(
1
)
text
=
match
.
group
(
1
)
...
...
tests/text/tests.py
Dosyayı görüntüle @
e7b9c11c
...
@@ -2,12 +2,16 @@
...
@@ -2,12 +2,16 @@
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.utils.encoding
import
iri_to_uri
from
django.utils.encoding
import
iri_to_uri
,
force_text
from
django.utils.functional
import
lazy
from
django.utils.http
import
(
cookie_date
,
http_date
,
from
django.utils.http
import
(
cookie_date
,
http_date
,
urlquote
,
urlquote_plus
,
urlunquote
,
urlunquote_plus
)
urlquote
,
urlquote_plus
,
urlunquote
,
urlunquote_plus
)
from
django.utils
import
six
from
django.utils.text
import
get_text_list
,
smart_split
from
django.utils.text
import
get_text_list
,
smart_split
from
django.utils.translation
import
override
from
django.utils.translation
import
override
lazystr
=
lazy
(
force_text
,
six
.
text_type
)
class
TextTests
(
TestCase
):
class
TextTests
(
TestCase
):
"""
"""
...
@@ -25,40 +29,36 @@ class TextTests(TestCase):
...
@@ -25,40 +29,36 @@ class TextTests(TestCase):
def
test_smart_split
(
self
):
def
test_smart_split
(
self
):
self
.
assertEqual
(
list
(
smart_split
(
r'''This is "a person" test.'''
)),
testdata
=
[
[
'This'
,
'is'
,
'"a person"'
,
'test.'
])
(
'This is "a person" test.'
,
[
'This'
,
'is'
,
'"a person"'
,
'test.'
]),
self
.
assertEqual
(
list
(
smart_split
(
r'''This is "a person's" test.'''
))[
2
],
(
'This is "a person
\'
s" test.'
,
'"a person
\'
s"'
)
[
'This'
,
'is'
,
'"a person
\'
s"'
,
'test.'
]),
(
'This is "a person
\\
"s" test.'
,
self
.
assertEqual
(
list
(
smart_split
(
r'''This is "a person\"s" test.'''
))[
2
],
[
'This'
,
'is'
,
'"a person
\\
"s"'
,
'test.'
]),
'"a person
\\
"s"'
)
(
'"a
\'
one'
,
[
'"a'
,
"'one"
]),
self
.
assertEqual
(
list
(
smart_split
(
'''"a 'one'''
)),
[
'"a'
,
"'one"
])
(
'all friends
\'
tests'
,
[
'all'
,
'friends
\'
'
,
'tests'
]),
self
.
assertEqual
(
list
(
smart_split
(
r'''all friends' tests'''
))[
1
],
(
'url search_page words="something else"'
,
"friends'"
)
[
'url'
,
'search_page'
,
'words="something else"'
]),
(
"url search_page words='something else'"
,
self
.
assertEqual
(
list
(
smart_split
(
'url search_page words="something else"'
)),
[
'url'
,
'search_page'
,
"words='something else'"
]),
[
'url'
,
'search_page'
,
'words="something else"'
])
(
'url search_page words "something else"'
,
[
'url'
,
'search_page'
,
'words'
,
'"something else"'
]),
self
.
assertEqual
(
list
(
smart_split
(
"url search_page words='something else'"
)),
(
'url search_page words-"something else"'
,
[
'url'
,
'search_page'
,
"words='something else'"
])
[
'url'
,
'search_page'
,
'words-"something else"'
]),
(
'url search_page words=hello'
,
self
.
assertEqual
(
list
(
smart_split
(
'url search_page words "something else"'
)),
[
'url'
,
'search_page'
,
'words=hello'
]),
[
'url'
,
'search_page'
,
'words'
,
'"something else"'
])
(
'url search_page words="something else'
,
[
'url'
,
'search_page'
,
'words="something'
,
'else'
]),
self
.
assertEqual
(
list
(
smart_split
(
'url search_page words-"something else"'
)),
(
"cut:','|cut:' '"
,
[
'url'
,
'search_page'
,
'words-"something else"'
])
[
"cut:','|cut:' '"
]),
(
lazystr
(
"a b c d"
),
# Test for #20231
self
.
assertEqual
(
list
(
smart_split
(
'url search_page words=hello'
)),
[
'a'
,
'b'
,
'c'
,
'd'
]),
[
'url'
,
'search_page'
,
'words=hello'
])
]
for
test
,
expected
in
testdata
:
self
.
assertEqual
(
list
(
smart_split
(
'url search_page words="something else'
)),
self
.
assertEqual
(
list
(
smart_split
(
test
)),
expected
)
[
'url'
,
'search_page'
,
'words="something'
,
'else'
])
self
.
assertEqual
(
list
(
smart_split
(
"cut:','|cut:' '"
)),
[
"cut:','|cut:' '"
])
def
test_urlquote
(
self
):
def
test_urlquote
(
self
):
self
.
assertEqual
(
urlquote
(
'Paris & Orl
\xe9
ans'
),
self
.
assertEqual
(
urlquote
(
'Paris & Orl
\xe9
ans'
),
...
...
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