https://github.com/arne-cl/pymox
mox: an object-mocking framework for Python (automatically exported from code.google.com/p/pymox)
https://github.com/arne-cl/pymox
Last synced: 10 months ago
JSON representation
mox: an object-mocking framework for Python (automatically exported from code.google.com/p/pymox)
- Host: GitHub
- URL: https://github.com/arne-cl/pymox
- Owner: arne-cl
- License: apache-2.0
- Created: 2015-08-13T07:27:14.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-08-14T06:56:13.000Z (over 10 years ago)
- Last Synced: 2025-01-06T09:12:23.826Z (12 months ago)
- Language: Python
- Homepage:
- Size: 234 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README
- License: COPYING
Awesome Lists containing this project
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:
https://github.com/arne-cl/pymox/tree/wiki
The original location of this library was:
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.