Skip to content

Instantly share code, notes, and snippets.

@pope
Created March 6, 2009 03:02
Show Gist options
  • Save pope/74723 to your computer and use it in GitHub Desktop.
Save pope/74723 to your computer and use it in GitHub Desktop.
def repeater(str):
return str + str
def hello():
return repeater("Hello")
import mox
import mymodule
class TestHello(mox.MoxTestBase):
def test_failing_hello(self):
self.mox.StubOutWithMock(mymodule, 'repeater')
mymodule.repeater("World").AndReturn("HelloWorld")
self.mox.ReplayAll()
mymodule.hello()
def test_successful_hello(self):
self.mox.StubOutWithMock(mymodule, 'repeater')
mymodule.repeater("Hello").AndReturn("HelloWorld")
self.mox.ReplayAll()
self.assertEqual("HelloWorld", mymodule.hello())
from setuptools import setup, find_packages
version = '0.1.0-SNAPSHOT'
setup(name='mox_test',
version=version,
description="Testing Mox",
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
zip_safe=False,
test_suite='nose.collector',
tests_require=['nose', 'mox'],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment