jeudi 3 mars 2016

How to test django admin form

I have a file called admin.py that has the following

class SomeFormset (BaseInlineFormSet):
   def something(self): 
       foo = False
       for unit in self.cleaned_data:
            try:
                foo = unit['someval']
            except KeyError:
                pass
       if foo
          raise ValidationError('Some error')

class SomeFormInline(admin.TabularInline):
        formset = SomeFormset
        model = SomeObject

I would like to write a test case for the if condition in this function. How can I do that? I have a test_forms.py file

Aucun commentaire:

Enregistrer un commentaire