Skip to main content

BuildStatus CoverageStatus Downloads License Docs

Test Helpers

The Test Helpers library aims to make Arrange-Act-Assert, class-based tests easier to write. The helpers in this module make patching easier, ease Python 3 compatibility, and gently guide users towards the AAA style of testing. Additional helpers are included for situations likely to be encountered in the web-app world.

Examples

The library is designed to be simple and modular. By using mixins to extend the test cases functionality we can write more expressive tests in fewer lines of code.

Creating Patches:

>>> from test_helpers import mixins, bases
>>> class WhenFooingBar(mixins.PatchMixin, bases.BaseTest):
...
...     patch_prefix = 'module.submodule'
...
...     @classmethod
...     def configure(cls):
...         cls.foo = cls.create_patch('foo', return_value=True)
...
...     @classmethod
...     def execute(cls):
...         function_under_test()
...
...     def should_have_called_foo(cls):
...         self.foo.assert_called_once_with()

Dependent Data Service Helpers

The Test Helpers library includes classes that facilitate initializing and cleaning up dependent data service resources. Provided with connection configuration to existing service instances, each class can generate name-spaced workspaces and tear down any created workspaces at the end of each test run.

Currently included:

  • MongoDB

  • PostgreSQL

  • RabbitMQ

Supported Python Versions

The Test Helpers library is built and tested against python 2.7, 3.3, 3.4, and 3.5. You may need to grab other versions of the interpreter with your preferred package manager (MacPorts, Apt, Yum, etc)

sudo port install python27 python33

Running Tests

To run the all of the tests across the supported versions of Python via tox run the following commands in your terminal:

$ virtualenv env
$ env/bin/pip install -r dev-requirements.txt
$ env/bin/detox

Developing The Test Helpers library

Clone the repo and start hacking:

$ virtualenv env
$ env/bin/pip install -r dev-requirements.txt

Authors

Dan Tracy, John Brodie, Dave Shawley at AWeber Communications

Release files for test-helpers 1.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for test-helpers 1.6.0
File Interpreter ABI Platform
test_helpers-1.6.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Release files / test_helpers-1.6.0-py2.py3-none-any.whl

Download URL test_helpers-1.6.0-py2.py3-none-any.whl
Size 19.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
b9cfdc0ec5f6d0cc8cff16f6c58ee238dab6ce44d450a6829bc516af6b6b0211
BLAKE2b-256 checksum
How to use checksums
e58a7dfb4f1c34b5871ceebdcc771fe96961e31403cad564fdf12b6da752431a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.6.0 This release

1 release file

1.5.4

1 release file

1.5.3

2 release files

1.5.1

1 release file

1.5.0

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page