RETIRED, Port of mox library to python 3
Go to file
Przemyslaw Gajda f25227371e Enabled Travis CI 2012-04-22 23:29:26 +02:00
.gitignore Added .gitignore 2012-04-22 22:44:36 +02:00
.travis.yml Enabled Travis CI 2012-04-22 23:29:26 +02:00
COPYING Initial import of mox (originally an internal Google project). 2008-06-13 23:00:27 +00:00
MANIFEST.in Mox release 0.5.1, which includes some bug fixes and tests for stubout. 2009-05-05 23:22:21 +00:00
README Write a README. 2008-06-18 23:30:15 +00:00
mox.py bugfix 2012-04-22 22:47:58 +02:00
mox_test.py Bugfix. At least I hope so... 2012-04-22 22:59:59 +02:00
mox_test_helper.py Another bugfix... Tests are still passing. 2012-04-22 23:01:29 +02:00
setup.py Updated to version 0.5.3 2012-04-22 17:45:03 +02:00
stubout.py Fix for Issue 5, submitted by agoratim. 2009-03-20 17:03:34 +00:00
stubout_test.py Added import for inspect, and tests for stubout. Patch by Manuel Holtgrewe. 2008-08-19 21:29:14 +00:00
stubout_testee.py Updated to version 0.5.3 2012-04-22 17:45:03 +02:00

README

Mox is an open source mock object framework for Python, inspired by
the Java library EasyMock.

To install:

  $ python setup.py install

To run Mox's internal tests:

  $ python mox_test.py

Basic usage:

  import unittest
  import mox

  class PersonTest(mox.MoxTestBase):

    def testUsingMox(self):
      # Create a mock Person
      mock_person = self.mox.CreateMock(Person)

      test_person = ...
      test_primary_key = ...
      unknown_person = ...

      # Expect InsertPerson to be called with test_person; return
      # test_primary_key at that point
      mock_person.InsertPerson(test_person).AndReturn(test_primary_key)

      # Raise an exception when this is called
      mock_person.DeletePerson(unknown_person).AndRaise(UnknownPersonError())

      # Switch from record mode to replay mode
      self.mox.ReplayAll()

      # Run the test
      ret_pk = mock_person.InsertPerson(test_person)
      self.assertEquals(test_primary_key, ret_pk)
      self.assertRaises(UnknownPersonError, mock_person, unknown_person)

For more documentation, see:

  http://code.google.com/p/pymox/wiki/MoxDocumentation

For more information, see:

  http://code.google.com/p/pymox/

Our user and developer discussion group is:

  http://groups.google.com/group/mox-discuss

Mox is Copyright 2008 Google Inc, and licensed under the Apache
License, Version 2.0; see the file COPYING for details.  If you would
like to help us improve Mox, join the group.