Skip to main content

Expects plugin for Doublex test doubles assertions

Project description

Latest version Number of PyPI downloads https://secure.travis-ci.org/jaimegildesagredo/doublex-expects.svg?branch=master

Doublex-Expects is a matchers library for the Expects assertion library. It provides matchers for the Doublex test double library.

Installation

You can install the last stable release from PyPI using pip or easy_install.

$ pip install doublex-expects

Also you can install the latest sources from Github.

$ pip install -e git+git://github.com/jaimegildesagredo/doublex-expects.git#egg=doublex-expects

Usage

Just import the expect callable and the Doublex-Expects matchers and start writing assertions for test doubles.

from expects import expect
from doublex_expects import *
from doublex import Spy

my_spy = Spy()

expect(my_spy.method).to(have_been_called)

Matchers

have_been_called

Assert that a spy has been called.

expect(my_spy.method).to(have_been_called)
expect(my_spy.method).not_to(have_been_called)

have_been_called_with

Assert that a spy has been called with given arguments.

expect(my_spy.method).to(have_been_called_with('foo', key='bar'))
expect(my_spy.method).not_to(have_been_called_with('bar', key='foo'))

Times called modifiers

once

Assert that a spy has been called exactly once.

expect(my_spy.method).to(have_been_called.once)
expect(my_spy.method).to(have_been_called_with('foo').once)
expect(my_spy.method).not_to(have_been_called.once)

twice

Assert that a spy has been called exactly twice.

expect(my_spy.method).to(have_been_called.twice)
expect(my_spy.method).to(have_been_called_with('foo').twice)
expect(my_spy.method).not_to(have_been_called.twice)

exactly

Assert that a spy has been called exactly n times.

expect(my_spy.method).to(have_been_called.exactly(3))
expect(my_spy.method).to(have_been_called_with('foo').exactly(3))
expect(my_spy.method).not_to(have_been_called.exactly(3))

max

Assert that a spy has been called maximum of n times.

expect(my_spy.method).to(have_been_called.max(2))
expect(my_spy.method).to(have_been_called_with('foo').max(2))
expect(my_spy.method).not_to(have_been_called.max(2))

min

Assert that a spy has been called minimum of n times.

expect(my_spy.method).to(have_been_called.min(2))
expect(my_spy.method).to(have_been_called_with('foo').min(2))
expect(my_spy.method).not_to(have_been_called.min(2))

Specs

To run the specs you should install the testing requirements and then run mamba.

$ python setup.py develop
$ pip install -r test-requirements.txt
$ mamba

License

The Doublex-Expects is released under the Apache2 license.

Project details


Release history Release notifications

History Node

0.7.0rc2

History Node

0.7.0rc1

History Node

0.6.0

History Node

0.5.0

This version
History Node

0.4.0

History Node

0.3.0

History Node

0.2.0

History Node

0.1.0

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
doublex-expects-0.4.0.tar.gz (4.2 kB) Copy SHA256 hash SHA256 Source None Aug 16, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page