problem writing a unittest
hi,
I am trying to write a unittest, but am getting an error.
django version - trunk
model:
class Nums(models.Model):
num1 = models.IntegerField("First number")
num2 = models.IntegerField("Second number")
def addit(self):
return self.num1+self.num2
test:
from django.utils import unittest
from addnums.models import Nums
class TestNums(unittest.TestCase):
def setup(self):
"""create a model and test if the result is correct"""
self.tnum = Nums.objects.create(num1=1,num2=2)
def testaddit(self):
self.assertEqual(self.tnum.addit(),"3")
and the error is:
Traceback (most recent call last):
File "/home/lawgon/addition/../addition/addnums/tests.py", line 18, in
testaddit
self.assertEqual(self.tnum.addit(),"3")
AttributeError: 'TestNums' object has no attribute 'tnum'
any clues?
--
regards
Kenneth Gonsalves
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home