def test_form(self):
    self.assertEqual(list(self.form_class.base_fields), ['name', 'tags'])
    f = self.form_class({'name': 'apple', 'tags': 'green, red, yummy'})
    self.assert_form_renders(f, '<tr><th><label for="id_name">Name:</label></th><td><input id="id_name" type="text" name="name" value="apple" maxlength="50" /></td></tr>\n<tr><th><label for="id_tags">Tags:</label></th><td><input type="text" name="tags" value="green, red, yummy" id="id_tags" /><br />%(help_start)sA comma-separated list of tags.%(help_stop)s</td></tr>')
    f.save()
    apple = self.food_model.objects.get(name='apple')
    self.assert_tags_equal(apple.tags.all(), ['green', 'red', 'yummy'])
    f = self.form_class({'name': 'apple', 'tags': 'green, red, yummy, delicious'}, instance=apple)
    f.save()
    apple = self.food_model.objects.get(name='apple')
    self.assert_tags_equal(apple.tags.all(), ['green', 'red', 'yummy', 'delicious'])
    self.assertEqual(self.food_model.objects.count(), 1)
    f = self.form_class({'name': 'raspberry'})
    self.assertFalse(f.is_valid())
    f = self.form_class(instance=apple)
    self.assert_form_renders(f, '<tr><th><label for="id_name">Name:</label></th><td><input id="id_name" type="text" name="name" value="apple" maxlength="50" /></td></tr>\n<tr><th><label for="id_tags">Tags:</label></th><td><input type="text" name="tags" value="delicious, green, red, yummy" id="id_tags" /><br />%(help_start)sA comma-separated list of tags.%(help_stop)s</td></tr>')
    apple.tags.add('has,comma')
    f = self.form_class(instance=apple)
    self.assert_form_renders(f, '<tr><th><label for="id_name">Name:</label></th><td><input id="id_name" type="text" name="name" value="apple" maxlength="50" /></td></tr>\n<tr><th><label for="id_tags">Tags:</label></th><td><input type="text" name="tags" value="&quot;has,comma&quot;, delicious, green, red, yummy" id="id_tags" /><br />%(help_start)sA comma-separated list of tags.%(help_stop)s</td></tr>')
    apple.tags.add('has space')
    f = self.form_class(instance=apple)
    self.assert_form_renders(f, '<tr><th><label for="id_name">Name:</label></th><td><input id="id_name" type="text" name="name" value="apple" maxlength="50" /></td></tr>\n<tr><th><label for="id_tags">Tags:</label></th><td><input type="text" name="tags" value="&quot;has space&quot;, &quot;has,comma&quot;, delicious, green, red, yummy" id="id_tags" /><br />%(help_start)sA comma-separated list of tags.%(help_stop)s</td></tr>')
def test_form(self):
    self.assertEqual(list(self.form_class.base_fields), ['name', 'tags'])
    f = self.form_class({'name': 'apple', 'tags': 'green, red, yummy'})
    self.assert_form_renders(f, '<tr><th><label for="id_name">Name:</label></th><td><input id="id_name" type="text" name="name" value="apple" maxlength="50" /></td></tr>\n<tr><th><label for="id_tags">Tags:</label></th><td><input type="text" name="tags" value="green, red, yummy" id="id_tags" /><br />%(help_start)sA comma-separated list of tags.%(help_stop)s</td></tr>')
    f.save()
    apple = self.food_model.objects.get(name='apple')
    self.assert_tags_equal(apple.tags.all(), ['green', 'red', 'yummy'])
    f = self.form_class({'name': 'apple', 'tags': 'green, red, yummy, delicious'}, instance=apple)
    f.save()
    apple = self.food_model.objects.get(name='apple')
    self.assert_tags_equal(apple.tags.all(), ['green', 'red', 'yummy', 'delicious'])
    self.assertEqual(self.food_model.objects.count(), 1)
    f = self.form_class({'name': 'raspberry'})
    self.assertFalse(f.is_valid())
    f = self.form_class(instance=apple)
    self.assert_form_renders(f, '<tr><th><label for="id_name">Name:</label></th><td><input id="id_name" type="text" name="name" value="apple" maxlength="50" /></td></tr>\n<tr><th><label for="id_tags">Tags:</label></th><td><input type="text" name="tags" value="delicious, green, red, yummy" id="id_tags" /><br />%(help_start)sA comma-separated list of tags.%(help_stop)s</td></tr>')
    apple.tags.add('has,comma')
    f = self.form_class(instance=apple)
    self.assert_form_renders(f, '<tr><th><label for="id_name">Name:</label></th><td><input id="id_name" type="text" name="name" value="apple" maxlength="50" /></td></tr>\n<tr><th><label for="id_tags">Tags:</label></th><td><input type="text" name="tags" value="&quot;has,comma&quot;, delicious, green, red, yummy" id="id_tags" /><br />%(help_start)sA comma-separated list of tags.%(help_stop)s</td></tr>')
    apple.tags.add('has space')
    f = self.form_class(instance=apple)
    self.assert_form_renders(f, '<tr><th><label for="id_name">Name:</label></th><td><input id="id_name" type="text" name="name" value="apple" maxlength="50" /></td></tr>\n<tr><th><label for="id_tags">Tags:</label></th><td><input type="text" name="tags" value="&quot;has space&quot;, &quot;has,comma&quot;, delicious, green, red, yummy" id="id_tags" /><br />%(help_start)sA comma-separated list of tags.%(help_stop)s</td></tr>')