'Issue #20522
Verifying that if the parent form fails validation, the inlines also
run validation even if validation is contingent on parent form data.
Also, assertFormError() and assertFormsetError() is usable for admin
forms and formsets.'

def test_add_view_form_and_formsets_run_validation(self):

    post_data = {'family_name': 'Test1', 'dependentchild_set-TOTAL_FORMS': '1', 'dependentchild_set-INITIAL_FORMS': '0', 'dependentchild_set-MAX_NUM_FORMS': '1', 'dependentchild_set-0-id': '', 'dependentchild_set-0-parent': '', 'dependentchild_set-0-family_name': 'Test2'}
    response = self.client.post(reverse('admin:admin_views_parentwithdependentchildren_add'), post_data)
    self.assertFormError(response, 'adminform', 'some_required_info', ['This    field    is    required.'])
    msg = "The    form    'adminform'    in    context    0    does    not    contain    the    non-field    error    'Error'"
    with self.assertRaisesMessage(AssertionError, msg):
        self.assertFormError(response, 'adminform', None, ['Error'])
    self.assertFormsetError(response, 'inline_admin_formset', 0, None, ['Children    must    share    a    family    name    with    their    parents    in    this    contrived    test    case'])
    msg = "The    formset    'inline_admin_formset'    in    context    10    does    not    contain    any    non-form    errors."
    with self.assertRaisesMessage(AssertionError, msg):
        self.assertFormsetError(response, 'inline_admin_formset', None, None, ['Error'])
