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

Run the tests

pip install nose
nosetests

Quick Start

Start with an empty stub:

from mockito import *

obj = mock()

# pass it around, eventually it will be used
obj.say('Hi')

# back in the tests, verify interactions
verify(obj).say('Hi')
verifyNoMoreInteractions(obj)

Or, say you want to mock the class Dog:

class Dog(object):
    def bark(self, sound):
        return "%s!" % sound


# mock the class
when(Dog).bark('Wuff').thenReturn('Miau!')

# instantiate
rex = Dog()
assert rex.bark('Wuff') == 'Miau!'

unstub()

Read the docs

http://pythonhosted.org/mockito/

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-0.7.0.tar.gz (17.0 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: mockito-0.7.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mockito-0.7.0.tar.gz
Algorithm Hash digest
SHA256 f8e74165c6edfbcfc70bcaa850420da19a0eea1e890266466b780d7289f0bf6d
MD5 0799104177dba5ce3fff1a1ac1bed740
BLAKE2b-256 3718efa2ab4c1941a63cedaebb5ab9b4b9f7199a60704b165cf1fa10f13b4661

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