Skip to content

Instantly share code, notes, and snippets.

@goodwillcoding
Last active December 10, 2015 19:18
Show Gist options
  • Save goodwillcoding/4480328 to your computer and use it in GitHub Desktop.
Save goodwillcoding/4480328 to your computer and use it in GitHub Desktop.
class Foo(object):
def bar(value):
if value == 11:
raise ValueError()
return value
def hello(msg):
return msg
class TestFoo_bar(TestCase):
def _makeOne(self, *args, **kwargs):
from foo import Foo
return Foo(*args, **kwargs)
def _callMUT(self, __one, *args, **kwargs):
__one.bar(*args, **kwargs)
def test_bar(self):
test_value = 10
foo = self._makeOne():
self.assertEqual(self._callFUT(__one=foo, test_value), test_value)
def test_bar_for_exception(self):
test_value = 11
foo = self._makeOne():
self.assertRaises(ValueError, self._callMUT, foo, test_value)
class TestFoo_hello(TestCase):
def _makeOne(self, *args, **kwargs):
from foo import Foo
return Foo(*args, **kwargs)
def _callMUT(self, __one, *args, **kwargs):
__one.hello(*args, **kwargs)
def test_hello(self):
test_msg = 'test_message'
foo = self._makeOne():
self.assertEqual(self._callMUT(__one=foo, test_msg), test_msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment