Link1
De Wiki de EGC
class VotingModelTestCase(BaseTestCase):
def setUp(self):
q = Question(desc='Descripcion')
q.save()
opt1 = QuestionOption(question=q, option='opcion 1')
opt1.save()
opt1 = QuestionOption(question=q, option='opcion 2')
opt1.save()
self.v = Voting(name='Votacion', question=q)
self.v.save()
super().setUp()
def tearDown(self):
super().tearDown()
self.v = None
def testExist(self):
v=Voting.objects.get(name='Votacion')
self.assertEquals(v.question.options.all()[0].option, "opcion 1")