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
48235ba8
Kaydet (Commit)
48235ba8
authored
May 09, 2019
tarafından
Jon Dufresne
Kaydeden (comit)
Carlton Gibson
May 09, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #30399 -- Made assertHTMLEqual normalize character and entity references.
üst
af5ec222
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
11 deletions
+40
-11
html.py
django/test/html.py
+6
-9
3.0.txt
docs/releases/3.0.txt
+5
-0
tools.txt
docs/topics/testing/tools.txt
+4
-2
tests.py
tests/test_utils/tests.py
+25
-0
No files found.
django/test/html.py
Dosyayı görüntüle @
48235ba8
...
...
@@ -3,11 +3,14 @@
import
re
from
html.parser
import
HTMLParser
WHITESPACE
=
re
.
compile
(
r'\s+'
)
# ASCII whitespace is U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, or U+0020
# SPACE.
# https://infra.spec.whatwg.org/#ascii-whitespace
ASCII_WHITESPACE
=
re
.
compile
(
r'[\t\n\f\r ]+'
)
def
normalize_whitespace
(
string
):
return
WHITESPACE
.
sub
(
' '
,
string
)
return
ASCII_
WHITESPACE
.
sub
(
' '
,
string
)
class
Element
:
...
...
@@ -144,7 +147,7 @@ class Parser(HTMLParser):
)
def
__init__
(
self
):
super
()
.
__init__
(
convert_charrefs
=
False
)
super
()
.
__init__
()
self
.
root
=
RootElement
()
self
.
open_tags
=
[]
self
.
element_positions
=
{}
...
...
@@ -202,12 +205,6 @@ class Parser(HTMLParser):
def
handle_data
(
self
,
data
):
self
.
current
.
append
(
data
)
def
handle_charref
(
self
,
name
):
self
.
current
.
append
(
'&
%
s;'
%
name
)
def
handle_entityref
(
self
,
name
):
self
.
current
.
append
(
'&
%
s;'
%
name
)
def
parse_html
(
html
):
"""
...
...
docs/releases/3.0.txt
Dosyayı görüntüle @
48235ba8
...
...
@@ -246,6 +246,11 @@ Tests
* Tests and test cases to run can be selected by test name pattern using the
new :option:`test -k` option.
* HTML comparison, as used by
:meth:`~django.test.SimpleTestCase.assertHTMLEqual`, now treats text, character
references, and entity references that refer to the same character as
equivalent.
URLs
~~~~
...
...
docs/topics/testing/tools.txt
Dosyayı görüntüle @
48235ba8
...
...
@@ -1603,14 +1603,16 @@ your test suite.
* The ordering of attributes of an HTML element is not significant.
* Attributes without an argument are equal to attributes that equal in
name and value (see the examples).
* Text, character references, and entity references that refer to the same
character are equivalent.
The following examples are valid tests and don't raise any
``AssertionError``::
self.assertHTMLEqual(
'<p>Hello <b>
world
!</p>',
'<p>Hello <b>
'world'
!</p>',
'''<p>
Hello <b>
world
! </b>
Hello <b>
'world'
! </b>
</p>'''
)
self.assertHTMLEqual(
...
...
tests/test_utils/tests.py
Dosyayı görüntüle @
48235ba8
...
...
@@ -612,6 +612,31 @@ class HTMLEqualTests(SimpleTestCase):
'<input type="text" id="id_name" />'
,
'<input type="password" id="id_name" />'
)
def
test_normalize_refs
(
self
):
pairs
=
[
(
'''
,
'''
),
(
'''
,
"'"
),
(
'''
,
'''
),
(
'''
,
"'"
),
(
"'"
,
'''
),
(
"'"
,
'''
),
(
'&'
,
'&'
),
(
'&'
,
'&'
),
(
'&'
,
'&'
),
(
'&'
,
'&'
),
(
'&'
,
'&'
),
(
'&'
,
'&'
),
(
'&'
,
'&'
),
(
'&'
,
'&'
),
(
'&'
,
'&'
),
(
'&'
,
'&'
),
(
'&'
,
'&'
),
(
'&'
,
'&'
),
]
for
pair
in
pairs
:
with
self
.
subTest
(
repr
(
pair
)):
self
.
assertHTMLEqual
(
*
pair
)
def
test_complex_examples
(
self
):
self
.
assertHTMLEqual
(
"""<tr><th><label for="id_first_name">First name:</label></th>
...
...
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