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
6b0a836c
Kaydet (Commit)
6b0a836c
authored
Eki 15, 2012
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed assertXMLEqual when first node was a comment
üst
1636b033
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
5 deletions
+16
-5
utils.py
django/test/utils.py
+11
-5
tests.py
tests/regressiontests/test_utils/tests.py
+5
-0
No files found.
django/test/utils.py
Dosyayı görüntüle @
6b0a836c
...
...
@@ -227,9 +227,10 @@ class override_settings(object):
def
compare_xml
(
want
,
got
):
"""Tries to do a 'xml-comparision' of want and got. Plain string
comparision doesn't always work because, for example, attribute
ordering should not be important.
"""Tries to do a 'xml-comparison' of want and got. Plain string
comparison doesn't always work because, for example, attribute
ordering should not be important. Comment nodes are not considered in the
comparison.
Based on http://codespeak.net/svn/lxml/trunk/src/lxml/doctestcompare.py
"""
...
...
@@ -267,6 +268,11 @@ def compare_xml(want, got):
return
False
return
True
def
first_node
(
document
):
for
node
in
document
.
childNodes
:
if
node
.
nodeType
!=
Node
.
COMMENT_NODE
:
return
node
want
,
got
=
strip_quotes
(
want
,
got
)
want
=
want
.
replace
(
'
\\
n'
,
'
\n
'
)
got
=
got
.
replace
(
'
\\
n'
,
'
\n
'
)
...
...
@@ -279,8 +285,8 @@ def compare_xml(want, got):
got
=
wrapper
%
got
# Parse the want and got strings, and compare the parsings.
want_root
=
parseString
(
want
)
.
firstChild
got_root
=
parseString
(
got
)
.
firstChild
want_root
=
first_node
(
parseString
(
want
))
got_root
=
first_node
(
parseString
(
got
))
return
check_element
(
want_root
,
got_root
)
...
...
tests/regressiontests/test_utils/tests.py
Dosyayı görüntüle @
6b0a836c
...
...
@@ -484,6 +484,11 @@ class XMLEqualTests(TestCase):
with
self
.
assertRaises
(
AssertionError
):
self
.
assertXMLNotEqual
(
xml_unvalid
,
xml2
)
def
test_comment_root
(
self
):
xml1
=
"<?xml version='1.0'?><!-- comment1 --><elem attr1='a' attr2='b' />"
xml2
=
"<?xml version='1.0'?><!-- comment2 --><elem attr2='b' attr1='a' />"
self
.
assertXMLEqual
(
xml1
,
xml2
)
class
SkippingExtraTests
(
TestCase
):
fixtures
=
[
'should_not_be_loaded.json'
]
...
...
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