skip to navigation
skip to content

Not Logged In

doublex-expects 0.3.0

Expects plugin for Doublex test doubles assertions

Latest Version: 0.5.0

This is an addon plugin for the Expects assertion library. It provides assertions for the Doublex test double library.

Installation

First you need to have Expects installed.

$ pip install expects>=0.3

You can install the last stable release of Doublex-Expects 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

There is nothing special you need to do. Just import the expect callable and start writing assertions for test doubles.

from expects import expect
from doublex import Spy

my_spy = Spy()

expect(my_spy.method).to.have.been.called()

Assertions

called

Assert that a spy has been called. Negation passes through.

expect(my_spy.method).to.have.been.called()
expect(my_spy.method).to.have.not_been.called()

Note that called can be used as a chainable property.

once

Assert that a spy has been called exactly once.

expect(my_spy.method).to.have.been.called.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).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).not_to.have.been.called.exactly(3)

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).not_to.have.been.called.min(2)

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).not_to.have.been.called.max(2)

with_args

Assert that a spy has been called with given arguments.

expect(my_spy.method).to.have.been.called.with_args('foo', key='bar')
expect(my_spy.method).not_to.have.been.called.with_args('bar', key='foo')

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.

 
File Type Py Version Uploaded on Size
doublex-expects-0.3.0.tar.gz (md5) Source 2014-07-10 3KB
  • Downloads (All Versions):
  • 10 downloads in the last day
  • 82 downloads in the last week
  • 116 downloads in the last month