          # The form should still have an instance of a model that is not complete and
          # not saved into a DB yet.
  
          self.assertEqual(form.instance.price, Decimal('6.00'))
          self.assertEqual(form.instance.quantity is None, True)
          self.assertEqual(form.instance.pk is None, True)
  
          # Choices on CharField and IntegerField
          f = ArticleForm()
          with self.assertRaises(ValidationError):
              f.fields['status'].clean('42')
 
</s> remove         self.assertEqual(form.is_valid(), True)
 </s> add         self.assertTrue(form.is_valid()) </s> remove         self.assertEqual(form.is_valid(), True)
 </s> add         self.assertTrue(form.is_valid()) </s> remove </select></td></tr>''' % (w_woodward.pk, w_royko.pk, c1.pk, c2.pk, c3.pk))

        # You can restrict a form to a subset of the complete list of fields
        # by providing a 'fields' argument. If you try to save a
        # model created with such a form, you need to ensure that the fields
        # that are _not_ on the form have default values, or are allowed to have
        # a value of None. If a field isn't specified on a form, the object created
        # from the form can't provide a value for that field!
        f = PartialArticleForm(auto_id=False)
        self.assertHTMLEqual(six.text_type(f), '''<tr><th>Headline:</th><td><input type="text" name="headline" maxlength="50" /></td></tr>
<tr><th>Pub date:</th><td><input type="text" name="pub_date" /></td></tr>''')
 </s> add </select></td></tr>''' % (self.w_woodward.pk, self.w_royko.pk, self.c1.pk, self.c2.pk, self.c3.pk)) </s> remove         new_art = Article.objects.get(id=art_id_4)
 </s> add         new_art = Article.objects.get(id=art_id_3) </s> remove         # When the ModelForm is passed an instance, that instance's current values are
        # inserted as 'initial' data in each Field.
        w = Writer.objects.get(name='Mike Royko')
        f = RoykoForm(auto_id=False, instance=w)
        self.assertHTMLEqual(six.text_type(f), '''<tr><th>Name:</th><td><input type="text" name="name" value="Mike Royko" maxlength="50" /><br /><span class="helptext">Use both first and last names.</span></td></tr>''')

        art = Article(
            headline='Test article',
            slug='test-article',
            pub_date=datetime.date(1988, 1, 4),
            writer=w,
            article='Hello.'
        )
        art.save()
        art_id_1 = art.id
        self.assertEqual(art_id_1 is not None, True)
        f = TestArticleForm(auto_id=False, instance=art)
        self.assertHTMLEqual(f.as_ul(), '''<li>Headline: <input type="text" name="headline" value="Test article" maxlength="50" /></li>
<li>Slug: <input type="text" name="slug" value="test-article" maxlength="50" /></li>
 </s> add         # Add some categories and test the many-to-many form output.
        new_art = Article.objects.create(
            article="Hello.", headline="New headline", slug="new-headline",
            pub_date=datetime.date(1988, 1, 4), writer=self.w_royko)
        new_art.categories.add(Category.objects.get(name='Entertainment'))
        self.assertQuerysetEqual(new_art.categories.all(), ["Entertainment"])
        f = ArticleForm(auto_id=False, instance=new_art)
        self.assertHTMLEqual(f.as_ul(), '''<li>Headline: <input type="text" name="headline" value="New headline" maxlength="50" /></li>
<li>Slug: <input type="text" name="slug" value="new-headline" maxlength="50" /></li>
        self.assertIsNone(form.instance.quantity)
        self.assertIsNone(form.instance.pk)
          # The form should still have an instance of a model that is not complete and
          # not saved into a DB yet.
  
          self.assertEqual(form.instance.price, Decimal('6.00'))
        self.assertIsNone(form.instance.quantity)
        self.assertIsNone(form.instance.pk)
        self.assertIsNone(form.instance.quantity)
        self.assertIsNone(form.instance.pk)
  
          # Choices on CharField and IntegerField
          f = ArticleForm()
          with self.assertRaises(ValidationError):
              f.fields['status'].clean('42')
keep keep keep keep replace replace keep keep keep keep keep
 Fixed #6103 -- Splitted tests in model_forms tests 
tests/model_forms/tests.py