Created
December 28, 2015 14:03
-
-
Save xiantail/4eae56f316f84770dbcb to your computer and use it in GitHub Desktop.
Introducing Python / Chapter 12 unittest
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
def just_do_it(text): | |
#Capitalize all words in <text> | |
return text.capitalize() |
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
import unittest | |
import cap | |
class TestCap(unittest.TestCase): | |
def setUp(self): | |
# Called just before test method | |
pass | |
def tearDown(self): | |
# Called just after test method | |
pass | |
def test_one_word(self): | |
text = 'duck' | |
result = cap.just_do_it(text) | |
self.assertEqual(result, 'Duck') | |
def test_multiple_words(self): | |
text = 'a veritable flock of ducks' | |
result = cap.just_do_it(text) | |
self.assertEqual(result, 'A Veritable Flock Of Ducks') | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment