Skip to content

Instantly share code, notes, and snippets.

@gahcep
Created February 10, 2013 13:33
Show Gist options
  • Save gahcep/4749595 to your computer and use it in GitHub Desktop.
Save gahcep/4749595 to your computer and use it in GitHub Desktop.
Article 'QA in Python - working with unittest'
import unittest
class FirstTestClass(unittest.TestCase):
def test_add(self):
self.assertEquals(120, 100 + 20)
class SecondTestClass(unittest.TestCase):
def test_sub(self):
self.val = 210
self.assertEquals(210, self.val)
self.val = self.val - 40
self.assertEquals(170, self.val)
def test_mul(self):
self.val = 210
self.assertEquals(420, self.val * 2)
if __name__ == '__main__':
unittest.main()
# CLI run options
# - pyexample_2.py -v
# - pyexample_2.py -v FirstTestClass
# - pyexample_2.py -v SecondTestClass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment