Created
November 8, 2013 17:05
-
-
Save raineorshine/7374199 to your computer and use it in GitHub Desktop.
Python Cheat Sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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