Skip to content
Automatically exported from
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
COPYING Initial import of mox (originally an internal Google project). Jun 13, 2008 Mox release 0.5.1, which includes some bug fixes and tests for stubout. May 5, 2009
README Write a README. Jun 18, 2008 Patch for Issue #47, provided by Nov 16, 2012 Patch for Issue 5438051 Nov 28, 2011 Fix for Issue 5, submitted by agoratim. Mar 20, 2009 Added import for inspect, and tests for stubout. Patch by Manuel Holt… Aug 19, 2008 Patch for Issue 5438051 Nov 28, 2011


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

To install:

  $ python install

To run Mox's internal tests:

  $ python

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

      # Raise an exception when this is called

      # Switch from record mode to replay mode

      # 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:

For more information, see:

Our user and developer discussion group is:

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.
You can’t perform that action at this time.