title: Python unittesting for a class method
body: <p>A beginner level question.. trying to understand how I can best use the built-in <code>unittest</code>. In the trivial example below, the method consume_food picks a food item and then I am calling <code>food.cut()</code> method.
  In future, this method may return instance of <code>Drink</code> object. The <code>#commented code</code> indicates one possible future implementation. In this case, <code>self.milk</code> will not have the cut method defined. </p>
  
  <p>I want to add a unit test for <code>consume_food</code> and <code>pick_food</code> methods. I would like to do this for the original implementation first and then change it after adding <code>self.milk</code> functionality. </p>
  
  <p><strong>EDIT:</strong> The intention is to write a unit test for an existing api, so that I can capture any such changes ( i.e. absence of <code>Drink.cut</code> method) forcing me to update the methods and unit tests. </p>
  
  <p>Can someone please help showing me how to write a unit test for this example?</p>
  
  <pre><code>class Fruit:
      def cut(self):
          print("cut the fruit")
  
  class Drink:
      def pour(self):
         print("pour the drink")
  
  
  class A:
     def __init__(self):
         self.apple = Fruit()
         self.banana=Fruit()
         #self.milk = Drink()
         #self.liquid_diet = True
  
     def consume_food(self):
         food = pick_food()
         food.cut()
         print("consuming the food")
  
     def pick_food(self):
         return self.apple                                 
         #if self.liquid_diet: return self.milk
         #return self.apple
  </code></pre>