Skip to main content

Spying framework

Project description

Mockito is a spying framework originally based on the Java library with the same name.

https://travis-ci.org/kaste/mockito-python.svg?branch=master

Install

pip install mockito

Quick Start

90% use case is that you want to stub out a side effect.

from mockito import when, mock, unstub

when(os.path).exists('/foo').thenReturn(True)

# or:
import requests  # the famous library
# you actually want to return a Response-like obj, we'll fake it
response = mock({'status_code': 200, 'text': 'Ok'})
when(requests).get(...).thenReturn(response)

# use it
requests.get('http://google.com/')

# clean up
unstub()

Read the docs

http://mockito-python.readthedocs.io/en/latest/

Run the tests

pip install pytest
py.test

Project details


Download files

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

Source Distribution

mockito-1.4.0.tar.gz (25.1 kB view details)

Uploaded Source

Built Distribution

mockito-1.4.0-py3-none-any.whl (30.3 kB view details)

Uploaded Python 3

File details

Details for the file mockito-1.4.0.tar.gz.

File metadata

  • Download URL: mockito-1.4.0.tar.gz
  • Upload date:
  • Size: 25.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for mockito-1.4.0.tar.gz
Algorithm Hash digest
SHA256 409ab604c9ebe1bb7dc18ec6b0ed98a8ad5127b08273f5804b22f4d1b51e5222
MD5 cf2f8cd4ca7df64ddcfd8b8cc0c8b870
BLAKE2b-256 f9fe80cb2b3f2291a6a6aa2b325bcbe851e9f9239d6fe781a47f2ba9182694cc

See more details on using hashes here.

File details

Details for the file mockito-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: mockito-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 30.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for mockito-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1719c6bec3523f9b465c86d247bb76027f53ab10f76b2a126dde409d0492fe3e
MD5 012523f2fca9993b909ad6570a991ac8
BLAKE2b-256 62010dd6622894ca019dea4e0582209deae2878cb7744532dab7114ad061708b

See more details on using hashes here.

Supported by

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