Skip to main content

Better expectation library

Project description

BASICS

Expecter Gadget helps you to write assertions. Never again will you forget which is expected and which is actual!

Basic expectations are easy:

>>> from expecter import expect
>>> expect('some' + 'thing') == 'something'
>>> expect(1) > 100
Traceback (most recent call last):
...
AssertionError: Expected something greater than 100 but got 1

Just read the expectations like a sentence. “expect(2) == 1 + 1” reads as “Expect 2 to equal 1 + 1”. Obviously, the expectation is about 2, and it’s being compared to 1 + 1. No ambiguity!

EXCEPTIONS

Expectations about exceptions use the “with” statement. Everything is good if the expected exception is raised:

>>> from __future__ import with_statement
>>> with expect.raises(KeyError):
...     {}[123]

If it’s not raised, Expecter Gadget will raise an AssertionError:

>>> with expect.raises(KeyError):
...     pass
Traceback (most recent call last):
...
AssertionError: Expected an exception of type KeyError but got none

Exceptions that don’t match the expected one will not be swallowed, so your test will error as you expect:

>>> from __future__ import with_statement
>>> with expect.raises(NameError):
...     {}[123]
Traceback (most recent call last):
...
KeyError: 123

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

expecter-0.1.1.tar.gz (1.9 kB view details)

Uploaded Source

File details

Details for the file expecter-0.1.1.tar.gz.

File metadata

  • Download URL: expecter-0.1.1.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for expecter-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9b466fdd4e6aba2490f5c65e8aef4e4590848e47934d39dc14a85826e6747e8c
MD5 32c24a87ee1a522db2ca60525bd6ff00
BLAKE2b-256 dd791b0f40675933e81c97712df71b887c427d7d019f663bf4081708c4f78750

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