Skip to content

Instantly share code, notes, and snippets.

@OddBloke
Last active June 27, 2016 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OddBloke/d9a3e87bd397878a77f21bb080e05275 to your computer and use it in GitHub Desktop.
Save OddBloke/d9a3e87bd397878a77f21bb080e05275 to your computer and use it in GitHub Desktop.
class MyTestCase(unittest.TestCase):
def setUp(self):
self.foo_patcher = patch('__main__.Class', spec=True)
self.foo_patcher.start()
def tearDown(self):
self.foo_patcher.stop()
class TestThingie(MyTestCase):
def test_thingie(self):
thingie()
self.assertEqual(1, self.foo_patcher.call_count)
class TestAnotherThing(MyTestCase):
def setUp(self):
super(TestAnotherThing, self).setUp() # <-- this is important
...
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment