1 Mox is an open source mock object framework for Python, inspired by
2 the Java library EasyMock.
6 $ python setup.py install
8 To run Mox's internal tests:
17 class PersonTest(mox.MoxTestBase):
19 def testUsingMox(self):
20 # Create a mock Person
21 mock_person = self.mox.CreateMock(Person)
24 test_primary_key = ...
27 # Expect InsertPerson to be called with test_person; return
28 # test_primary_key at that point
29 mock_person.InsertPerson(test_person).AndReturn(test_primary_key)
31 # Raise an exception when this is called
32 mock_person.DeletePerson(unknown_person).AndRaise(UnknownPersonError())
34 # Switch from record mode to replay mode
38 ret_pk = mock_person.InsertPerson(test_person)
39 self.assertEquals(test_primary_key, ret_pk)
40 self.assertRaises(UnknownPersonError, mock_person, unknown_person)
42 For more documentation, see:
44 http://code.google.com/p/pymox/wiki/MoxDocumentation
46 For more information, see:
48 http://code.google.com/p/pymox/
50 Our user and developer discussion group is:
52 http://groups.google.com/group/mox-discuss
54 Mox is Copyright 2008 Google Inc, and licensed under the Apache
55 License, Version 2.0; see the file COPYING for details. If you would
56 like to help us improve Mox, join the group.