mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Use new TestCase methods for equality comparisons
This commit is contained in:
parent
089d9ca1df
commit
8d35fd4c32
7 changed files with 26 additions and 20 deletions
|
@ -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.assertFalse(table_output.find(hiddenfields_div) == -1,
|
||||
'Failed to find hidden fields in: %s' % table_output)
|
||||
self.assertInHTML(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):
|
||||
"""
|
||||
|
|
|
@ -358,7 +358,7 @@ class TestFixtures(TestCase):
|
|||
format='json',
|
||||
stdout=stdout
|
||||
)
|
||||
self.assertEqual(
|
||||
self.assertJSONEqual(
|
||||
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.assertJSONEqual(
|
||||
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"]}}]"""
|
||||
)
|
||||
|
|
|
@ -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.assertTrue('<input type="text" name="products_delivered" value="12.000" id="id_products_delivered" />' in form6.as_ul())
|
||||
self.assertInHTML('<input type="text" name="products_delivered" value="12.000" id="id_products_delivered" />', form6.as_ul())
|
||||
|
||||
def test_iter_format_modules(self):
|
||||
"""
|
||||
|
|
|
@ -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.assertJSONEqual(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.assertXMLEqual(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.assertJSONEqual(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"}}]""")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue