| OLD | NEW |
| (Empty) |
| 1 Mox is an open source mock object framework for Python, inspired by | |
| 2 the Java library EasyMock. | |
| 3 | |
| 4 To install: | |
| 5 | |
| 6 $ python setup.py install | |
| 7 | |
| 8 To run Mox's internal tests: | |
| 9 | |
| 10 $ python mox_test.py | |
| 11 | |
| 12 Basic usage: | |
| 13 | |
| 14 import unittest | |
| 15 import mox | |
| 16 | |
| 17 class PersonTest(mox.MoxTestBase): | |
| 18 | |
| 19 def testUsingMox(self): | |
| 20 # Create a mock Person | |
| 21 mock_person = self.mox.CreateMock(Person) | |
| 22 | |
| 23 test_person = ... | |
| 24 test_primary_key = ... | |
| 25 unknown_person = ... | |
| 26 | |
| 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) | |
| 30 | |
| 31 # Raise an exception when this is called | |
| 32 mock_person.DeletePerson(unknown_person).AndRaise(UnknownPersonError()) | |
| 33 | |
| 34 # Switch from record mode to replay mode | |
| 35 self.mox.ReplayAll() | |
| 36 | |
| 37 # Run the test | |
| 38 ret_pk = mock_person.InsertPerson(test_person) | |
| 39 self.assertEquals(test_primary_key, ret_pk) | |
| 40 self.assertRaises(UnknownPersonError, mock_person, unknown_person) | |
| 41 | |
| 42 For more documentation, see: | |
| 43 | |
| 44 http://code.google.com/p/pymox/wiki/MoxDocumentation | |
| 45 | |
| 46 For more information, see: | |
| 47 | |
| 48 http://code.google.com/p/pymox/ | |
| 49 | |
| 50 Our user and developer discussion group is: | |
| 51 | |
| 52 http://groups.google.com/group/mox-discuss | |
| 53 | |
| 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. | |
| OLD | NEW |