Skip to main content

A Python mock object library

Project description

There are already several Python mocking libraries available, so why another one?

Most mocking libraries follow the ‘record -> replay’ pattern of mocking. I prefer the ‘action -> assertion’ pattern, which is more readable and intuitive particularly when working with the Python unittest module. For a discussion of the merits of the two approaches, see Mocking, Patching, Stubbing: all that Stuff.

mock provides a core Mock class that is intended to reduce the need to create a host of trivial stubs throughout your test suite. After performing an action, you can make assertions about which methods / attributes were used and arguments they were called with. You can also specify return values and set specific attributes in the normal way.

It also provides a patch decorator that handles patching module and class level attributes within the scope of a test, along with sentinel for creating unique objects.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mock-0.4.0-py2.6.egg (5.8 kB view details)

Uploaded Egg

mock-0.4.0-py2.5.egg (5.2 kB view details)

Uploaded Egg

mock-0.4.0-py2.4.egg (5.9 kB view details)

Uploaded Egg

File details

Details for the file mock-0.4.0-py2.6.egg.

File metadata

  • Download URL: mock-0.4.0-py2.6.egg
  • Upload date:
  • Size: 5.8 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mock-0.4.0-py2.6.egg
Algorithm Hash digest
SHA256 136d86d121fef17549bc55b24b8e6f5335e2d152ee7dea58c20535292db0f262
MD5 7e7ca9c58532bd5807c4a071336f28d0
BLAKE2b-256 0b6a5e3ead38ff3f10031f16f3c834037a1f6c454f54a63b54b56843cd98a7cc

See more details on using hashes here.

File details

Details for the file mock-0.4.0-py2.5.egg.

File metadata

  • Download URL: mock-0.4.0-py2.5.egg
  • Upload date:
  • Size: 5.2 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mock-0.4.0-py2.5.egg
Algorithm Hash digest
SHA256 232f8b4e1df369848e235c4fda85bba41e95b75be40674fea060c4fdee7ab04c
MD5 147f343ce516b6429883416cc5ffa7cd
BLAKE2b-256 d3ce3691e7e85b1d48178d2379227fbfe448a788a816ee8e883f71a5526ba1e4

See more details on using hashes here.

File details

Details for the file mock-0.4.0-py2.4.egg.

File metadata

  • Download URL: mock-0.4.0-py2.4.egg
  • Upload date:
  • Size: 5.9 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mock-0.4.0-py2.4.egg
Algorithm Hash digest
SHA256 cde44a12fb139ea1da4fe7a2d7d876a63a1e663444bc0a670f5ef5617c2fd6c2
MD5 e948e25b46f75d343a7fcdf24a36005c
BLAKE2b-256 337f031bd64d3acbf5447c107f55f592619eccdef6b30e87570592d413d6c9cc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page