Skip to main content

BDD / TDD assertion library for Python

Project description

Build Status Coverage Status Code Climate

robber.py - BDD / TDD assertion library for Python.

Synopsis

In order to use robber, you need to import expect from the module:

from robber import expect

That’s all. You are good to go.

Assertions

eq/==

Asserts that actual is equal (==) to expected:

expect(1).to.eq(1)
expect([1, 2]).to.eq([1, 2])

Also:

expect(1) == 1

ne/!=

Asserts that actual is not equal (!=) to expected:

expect(1).to.ne(2)
expect(1).to != 2
expect(1) != 2

equal

Asserts that the target is identical (is) to the expected:

expect(1).to.equal(1)

true

Asserts that the target is True:

expect(True).to.be.true()

false

Asserts that the target is False:

expect(False).to.be.false()

instanceof

Asserts that the target is an instance of expected:

expect(obj).to.be.instanceof(Klass)

match

Asserts that the target can be matched by a regular expression:

expect('foo').to.match(r'foo')

respond_to

Asserts that the target responds to a method:

expect(obj).to.respond_to('method')

truthy

Asserts that the target is truthy:

expect(['test']).to.be.truthy()

falsy

Asserts that the target is falsy:

expect([]).to.be.falsy()

length

Asserts that the target has a length of expected:

expect([1, 2]).to.have.length(2)
expect('str').to.have.length(3)

empty

Asserts that the target is empty:

expect([]).to.be.empty()
expect('').to.be.empty()

string

Asserts that the target is a string:

expect('str').to.be.a.string()

integer

Asserts that the target is an integer:

expect('str').to.be.an.integer()

float

Asserts that the target is floating point number:

expect(1.0).to.be.a.float()

list

Asserts that the target is a list:

expect([1, 2]).to.be.a.list()

dict

Asserts that the target is a dictionary:

expect({}).to.be.a.dict()

tuple

Asserts that the target is a tuple:

expect((1, 2)).to.be.a.tuple()

none

Asserts that the target is None:

expect(None).to.be.none()

above

Asserts that the target is above expected:

expect(2).to.be.above(1)

below

Asserts that the target is below expected:

expect(1).to.be.below(2)

within

Asserts that the target is within expected:

expect(2).to.be.within(0, 2)

contain

Asserts tha

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

robber-1.1.0.tar.gz (11.9 kB view hashes)

Uploaded Source

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