Skip to content

Instantly share code, notes, and snippets.

@xiantail
Created December 28, 2015 14:08
Show Gist options
  • Save xiantail/650146e30d52173eea59 to your computer and use it in GitHub Desktop.
Save xiantail/650146e30d52173eea59 to your computer and use it in GitHub Desktop.
Introducing Python / Chapter 12 unittest - retry no errors
def just_do_it(text):
#Capitalize all words in <text>
return text.title()
import unittest
import cap_new as 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