from contacts.models import Contact # import model Contact
...
class ContactTests(TestCase): # start a test case
"""Contact model tests."""
def test_str(self): # start one test
contact = Contact(first_name='John', last_name='Smith') # create a Contact object with 2 params like that
self.assertEquals( # check if str(contact) == 'John Smith'
str(contact),
'John Smith',
)
Basically it will check if str(contact) == 'John Smith', if not then assert equal is failed and the test is failed and it will notify you the error at that line.
In other words, assertEquals is a function to check if two variables are equal, for purposes of automated testing:
def assertEquals(var1, var2):
if var1 == var2:
return True
else:
return False
Hope it helps.
assertEquals
is deprecated --assertEqual
is now the correct method name -- docs.python.org/2/library/unittest.html#deprecated-aliases – Ose