Python Cheat Sheet
# importing
import sha # import the the sha module
from animal import Animal # import the Animal class from animal.py
# unit testing
# http://docs.python.org/3/library/unittest.html
import unittest
class AnimalTest(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test_grow(self):
lion = Animal('Lion')
self.assertEqual(lion.weight, 5, "Animal should start at 5 lbs")
lion.grow()
self.assertEqual(lion.weight, 6, "Animal weight should increase by 1 when grow is called")
unittest.main() # run unit tests
python3 -m unittest # run unit tests from the command line
python3 -m unittest animal # run unit tests in the animal module from the command line