

def test_form_field_on_model_field(self):

    class ShelfForm(forms.ModelForm):

        class Meta():
            model = Shelf
            fields = ('books',)
    form = ShelfForm()
    self.assertTrue(isinstance(form.fields['books'], SortedMultipleChoiceField))

    class MessyStoreForm(forms.ModelForm):

        class Meta():
            model = MessyStore
            fields = ('books',)
    form = MessyStoreForm()
    self.assertFalse(isinstance(form.fields['books'], SortedMultipleChoiceField))
    self.assertTrue(isinstance(form.fields['books'], forms.ModelMultipleChoiceField))

dataset/ETHPy150Open gregmuellegger/django-sortedm2m/sortedm2m_tests/test_forms.py TestSortedFormField.test_form_field_on_model_field/original