Thursday, 15 August 2013

python - How to test django model method __str__() -


I am trying to test the __str__ method, and when it tries to enter my test, it My model gives the example (I think this is)

  def test_str_is_equal_to_title (self): "" "method` __str__` field should be equal to` title` "=" = = work. Work.objects.get (pk = 1) self.assertEqual (work .__ str__, work.title)  

And I'm getting the test from:

 < Code> conditional error: '& lt; binding method work .__ & lt;: test How to compare these 2 values ​​to pass the test!?   

You call str () string model example:

  self.assertEqual (str (work), work.title)  

No comments:

Post a Comment