python - Test if a class is inherited from another -


this question more python related django related. want test write test function using django form dynamically fields set.

def quiz_form_factory(question):     properties = {         'question': forms.integerfield(widget=forms.hiddeninput, initial=question.id),         'answers': forms.modelchoicefield(queryset=question.answers_set)     }     return type('quizform', (forms.form,), properties) 

i want test if, quizform class returned inherited forms.form.

something like:

self.asserttrue(quizform isinheritedfrom forms.form)  # know not exist 

is there way this?

use issubclass(myclass, parentclass).

in case:

self.asserttrue( issubclass(quizform, forms.form) ) 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -