Ticket #26917: Refs__26917___Added_test_to_duplicate_problem___Added_test_to_duplicate_problem_in_which_a.patch

File Refs__26917___Added_test_to_duplicate_problem___Added_test_to_duplicate_problem_in_which_a.patch, 1.2 KB (added by Ryan Schave, 3 years ago)

Added unit test to duplicate problem

  • tests/model_forms/tests.py

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    15361536        field = CustomModelChoiceField(Category.objects.all())
    15371537        self.assertIsInstance(field.choices, CustomModelChoiceIterator)
    15381538
     1539    def test_modelchoicefield_26917(self):
     1540        """
     1541        #26917 -- Disabled ModelChoiceFields crash in Django 1.10
     1542        """
     1543
     1544        class ModelChoiceForm(forms.ModelForm):
     1545            author = forms.ModelChoiceField(Author.objects.all(), disabled=True)
     1546
     1547            class Meta:
     1548                model = Book
     1549                fields = ['title', 'author', 'special_id']
     1550
     1551        book = Book.objects.create(author=Writer.objects.create(name='Test writer'))
     1552        form_data = {
     1553            'title': 'Test Title',
     1554            'special_id': 1,
     1555        }
     1556        form = ModelChoiceForm(form_data, instance=book)
     1557        self.assertFalse(form.is_valid())
     1558
    15391559
    15401560class ModelMultipleChoiceFieldTests(TestCase):
    15411561    def setUp(self):
Back to Top