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
8d35fd4c
Kaydet (Commit)
8d35fd4c
authored
Eyl 28, 2012
tarafından
Ian Clelland
Kaydeden (comit)
Luke Plant
Ara 24, 2012
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Use new TestCase methods for equality comparisons
üst
089d9ca1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
20 deletions
+26
-20
cookiestorage.py
django/contrib/formtools/tests/wizard/cookiestorage.py
+1
-1
tests.py
tests/modeltests/field_subclassing/tests.py
+5
-1
tests.py
tests/modeltests/fixtures/tests.py
+11
-8
tests.py
tests/regressiontests/admin_changelist/tests.py
+3
-4
tests.py
tests/regressiontests/fixtures_regress/tests.py
+2
-2
tests.py
tests/regressiontests/i18n/tests.py
+1
-1
tests.py
tests/regressiontests/m2m_through_regress/tests.py
+3
-3
No files found.
django/contrib/formtools/tests/wizard/cookiestorage.py
Dosyayı görüntüle @
8d35fd4c
...
...
@@ -43,5 +43,5 @@ class TestCookieStorage(TestStorage, TestCase):
storage
.
init_data
()
storage
.
update_response
(
response
)
unsigned_cookie_data
=
cookie_signer
.
unsign
(
response
.
cookies
[
storage
.
prefix
]
.
value
)
self
.
assert
Equal
(
json
.
loads
(
unsigned_cookie_data
)
,
self
.
assert
JSONEqual
(
unsigned_cookie_data
,
{
"step_files"
:
{},
"step"
:
None
,
"extra_data"
:
{},
"step_data"
:
{}})
tests/modeltests/field_subclassing/tests.py
Dosyayı görüntüle @
8d35fd4c
...
...
@@ -61,7 +61,11 @@ class CustomField(TestCase):
# Serialization works, too.
stream
=
serializers
.
serialize
(
"json"
,
MyModel
.
objects
.
all
())
self
.
assertEqual
(
stream
,
'[{"pk":
%
d, "model": "field_subclassing.mymodel", "fields": {"data": "12", "name": "m"}}]'
%
m1
.
pk
)
self
.
assertJSONEqual
(
stream
,
[{
"pk"
:
m1
.
pk
,
"model"
:
"field_subclassing.mymodel"
,
"fields"
:
{
"data"
:
"12"
,
"name"
:
"m"
}
}])
obj
=
list
(
serializers
.
deserialize
(
"json"
,
stream
))[
0
]
self
.
assertEqual
(
obj
.
object
,
m
)
...
...
tests/modeltests/fixtures/tests.py
Dosyayı görüntüle @
8d35fd4c
...
...
@@ -22,7 +22,7 @@ class TestCaseFixtureLoadingTests(TestCase):
])
class
FixtureLoadingTests
(
TestCase
):
class
DumpDataAssertMixin
(
object
):
def
_dumpdata_assert
(
self
,
args
,
output
,
format
=
'json'
,
natural_keys
=
False
,
use_base_manager
=
False
,
exclude_list
=
[]):
...
...
@@ -34,7 +34,15 @@ class FixtureLoadingTests(TestCase):
'use_base_manager'
:
use_base_manager
,
'exclude'
:
exclude_list
})
command_output
=
new_io
.
getvalue
()
.
strip
()
self
.
assertEqual
(
command_output
,
output
)
if
format
==
"json"
:
self
.
assertJSONEqual
(
command_output
,
output
)
elif
format
==
"xml"
:
self
.
assertXMLEqual
(
command_output
,
output
)
else
:
self
.
assertEqual
(
command_output
,
output
)
class
FixtureLoadingTests
(
DumpDataAssertMixin
,
TestCase
):
def
test_initial_data
(
self
):
# syncdb introduces 1 initial data object from initial_data.json.
...
...
@@ -290,12 +298,7 @@ class FixtureLoadingTests(TestCase):
<django-objects version="1.0"><object pk="1" model="fixtures.category"><field type="CharField" name="title">News Stories</field><field type="TextField" name="description">Latest news stories</field></object><object pk="2" model="fixtures.article"><field type="CharField" name="headline">Poker has no place on ESPN</field><field type="DateTimeField" name="pub_date">2006-06-16T12:00:00</field></object><object pk="3" model="fixtures.article"><field type="CharField" name="headline">Time to reform copyright</field><field type="DateTimeField" name="pub_date">2006-06-16T13:00:00</field></object><object pk="1" model="fixtures.tag"><field type="CharField" name="name">copyright</field><field to="contenttypes.contenttype" name="tagged_type" rel="ManyToOneRel"><natural>fixtures</natural><natural>article</natural></field><field type="PositiveIntegerField" name="tagged_id">3</field></object><object pk="2" model="fixtures.tag"><field type="CharField" name="name">law</field><field to="contenttypes.contenttype" name="tagged_type" rel="ManyToOneRel"><natural>fixtures</natural><natural>article</natural></field><field type="PositiveIntegerField" name="tagged_id">3</field></object><object pk="1" model="fixtures.person"><field type="CharField" name="name">Django Reinhardt</field></object><object pk="2" model="fixtures.person"><field type="CharField" name="name">Stephane Grappelli</field></object><object pk="3" model="fixtures.person"><field type="CharField" name="name">Prince</field></object><object pk="10" model="fixtures.book"><field type="CharField" name="name">Achieving self-awareness of Python programs</field><field to="fixtures.person" name="authors" rel="ManyToManyRel"></field></object></django-objects>"""
,
format
=
'xml'
,
natural_keys
=
True
)
class
FixtureTransactionTests
(
TransactionTestCase
):
def
_dumpdata_assert
(
self
,
args
,
output
,
format
=
'json'
):
new_io
=
six
.
StringIO
()
management
.
call_command
(
'dumpdata'
,
*
args
,
**
{
'format'
:
format
,
'stdout'
:
new_io
})
command_output
=
new_io
.
getvalue
()
.
strip
()
self
.
assertEqual
(
command_output
,
output
)
class
FixtureTransactionTests
(
DumpDataAssertMixin
,
TransactionTestCase
):
@skipUnlessDBFeature
(
'supports_forward_references'
)
def
test_format_discovery
(
self
):
...
...
tests/regressiontests/admin_changelist/tests.py
Dosyayı görüntüle @
8d35fd4c
...
...
@@ -122,12 +122,11 @@ class ChangeListTests(TestCase):
table_output
=
template
.
render
(
context
)
# make sure that hidden fields are in the correct place
hiddenfields_div
=
'<div class="hiddenfields"><input type="hidden" name="form-0-id" value="
%
d" id="id_form-0-id" /></div>'
%
new_child
.
id
self
.
assert
False
(
table_output
.
find
(
hiddenfields_div
)
==
-
1
,
'Failed to find hidden fields in:
%
s'
%
table_output
)
self
.
assert
InHTML
(
hiddenfields_div
,
table_output
,
msg_prefix
=
'Failed to find hidden fields'
)
# make sure that list editable fields are rendered in divs correctly
editable_name_field
=
'<input name="form-0-name" value="name" class="vTextField" maxlength="30" type="text" id="id_form-0-name" />'
self
.
assertFalse
(
'<td>
%
s</td>'
%
editable_name_field
==
-
1
,
'Failed to find "name" list_editable field in:
%
s'
%
table_output
)
self
.
assertInHTML
(
'<td>
%
s</td>'
%
editable_name_field
,
table_output
,
msg_prefix
=
'Failed to find "name" list_editable field'
)
def
test_result_list_editable
(
self
):
"""
...
...
tests/regressiontests/fixtures_regress/tests.py
Dosyayı görüntüle @
8d35fd4c
...
...
@@ -358,7 +358,7 @@ class TestFixtures(TestCase):
format
=
'json'
,
stdout
=
stdout
)
self
.
assertEqual
(
self
.
assert
JSON
Equal
(
stdout
.
getvalue
(),
"""[{"pk":
%
d, "model": "fixtures_regress.widget", "fields": {"name": "grommet"}}]"""
%
widget
.
pk
...
...
@@ -519,7 +519,7 @@ class NaturalKeyFixtureTests(TestCase):
use_natural_keys
=
True
,
stdout
=
stdout
,
)
self
.
assertEqual
(
self
.
assert
JSON
Equal
(
stdout
.
getvalue
(),
"""[{"pk": 2, "model": "fixtures_regress.store", "fields": {"main": null, "name": "Amazon"}}, {"pk": 3, "model": "fixtures_regress.store", "fields": {"main": null, "name": "Borders"}}, {"pk": 4, "model": "fixtures_regress.person", "fields": {"name": "Neal Stephenson"}}, {"pk": 1, "model": "fixtures_regress.book", "fields": {"stores": [["Amazon"], ["Borders"]], "name": "Cryptonomicon", "author": ["Neal Stephenson"]}}]"""
)
...
...
tests/regressiontests/i18n/tests.py
Dosyayı görüntüle @
8d35fd4c
...
...
@@ -634,7 +634,7 @@ class FormattingTests(TestCase):
self
.
assertEqual
(
datetime
.
datetime
(
2009
,
12
,
31
,
6
,
0
,
0
),
form6
.
cleaned_data
[
'date_added'
])
with
self
.
settings
(
USE_THOUSAND_SEPARATOR
=
True
):
# Checking for the localized "products_delivered" field
self
.
assert
True
(
'<input type="text" name="products_delivered" value="12.000" id="id_products_delivered" />'
in
form6
.
as_ul
())
self
.
assert
InHTML
(
'<input type="text" name="products_delivered" value="12.000" id="id_products_delivered" />'
,
form6
.
as_ul
())
def
test_iter_format_modules
(
self
):
"""
...
...
tests/regressiontests/m2m_through_regress/tests.py
Dosyayı görüntüle @
8d35fd4c
...
...
@@ -73,12 +73,12 @@ class M2MThroughTestCase(TestCase):
out
=
StringIO
()
management
.
call_command
(
"dumpdata"
,
"m2m_through_regress"
,
format
=
"json"
,
stdout
=
out
)
self
.
assertEqual
(
out
.
getvalue
()
.
strip
(),
"""[{"pk":
%(m_pk)
s, "model": "m2m_through_regress.membership", "fields": {"person":
%(p_pk)
s, "price": 100, "group":
%(g_pk)
s}}, {"pk":
%(p_pk)
s, "model": "m2m_through_regress.person", "fields": {"name": "Bob"}}, {"pk":
%(g_pk)
s, "model": "m2m_through_regress.group", "fields": {"name": "Roll"}}]"""
%
pks
)
self
.
assert
JSON
Equal
(
out
.
getvalue
()
.
strip
(),
"""[{"pk":
%(m_pk)
s, "model": "m2m_through_regress.membership", "fields": {"person":
%(p_pk)
s, "price": 100, "group":
%(g_pk)
s}}, {"pk":
%(p_pk)
s, "model": "m2m_through_regress.person", "fields": {"name": "Bob"}}, {"pk":
%(g_pk)
s, "model": "m2m_through_regress.group", "fields": {"name": "Roll"}}]"""
%
pks
)
out
=
StringIO
()
management
.
call_command
(
"dumpdata"
,
"m2m_through_regress"
,
format
=
"xml"
,
indent
=
2
,
stdout
=
out
)
self
.
assertEqual
(
out
.
getvalue
()
.
strip
(),
"""
self
.
assert
XML
Equal
(
out
.
getvalue
()
.
strip
(),
"""
<?xml version="1.0" encoding="utf-8"?>
<django-objects version="1.0">
<object pk="
%(m_pk)
s" model="m2m_through_regress.membership">
...
...
@@ -232,4 +232,4 @@ class ThroughLoadDataTestCase(TestCase):
"Check that sequences on an m2m_through are created for the through model, not a phantom auto-generated m2m table. Refs #11107"
out
=
StringIO
()
management
.
call_command
(
"dumpdata"
,
"m2m_through_regress"
,
format
=
"json"
,
stdout
=
out
)
self
.
assertEqual
(
out
.
getvalue
()
.
strip
(),
"""[{"pk": 1, "model": "m2m_through_regress.usermembership", "fields": {"price": 100, "group": 1, "user": 1}}, {"pk": 1, "model": "m2m_through_regress.person", "fields": {"name": "Guido"}}, {"pk": 1, "model": "m2m_through_regress.group", "fields": {"name": "Python Core Group"}}]"""
)
self
.
assert
JSON
Equal
(
out
.
getvalue
()
.
strip
(),
"""[{"pk": 1, "model": "m2m_through_regress.usermembership", "fields": {"price": 100, "group": 1, "user": 1}}, {"pk": 1, "model": "m2m_through_regress.person", "fields": {"name": "Guido"}}, {"pk": 1, "model": "m2m_through_regress.group", "fields": {"name": "Python Core Group"}}]"""
)
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