Skip to content

Instantly share code, notes, and snippets.

@raineorshine
Created November 8, 2013 17:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raineorshine/7374199 to your computer and use it in GitHub Desktop.
Save raineorshine/7374199 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment