A collection of test helpers to facilitate AAA testing.
Project description
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.6, 2.7, and 3.3. 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:
make test
Developing The Test Helpers library
Clone the repo and start hacking:
$ make requirements # If you just cloned the repo or requirements.pip changes $ make test # Run the tests afterwards to ensure everything is running as expected
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
Built Distribution
File details
Details for the file test-helpers-1.5.3.tar.gz
.
File metadata
- Download URL: test-helpers-1.5.3.tar.gz
- Upload date:
- Size: 21.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50be1fab59164c1096119c07fb6c751e6e4e4f6a19f44fb6159b889679352808 |
|
MD5 | b68431db10f57f6419c42ce0b55f5f62 |
|
BLAKE2b-256 | ad8871de30a708bd94218c9e39bffddd3e438b50b0b65dda7694084855c04b9d |
File details
Details for the file test_helpers-1.5.3-py2-none-any.whl
.
File metadata
- Download URL: test_helpers-1.5.3-py2-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b723cb706ad98dc520e05c728ba73c374768349383b33367467bf95f21df0647 |
|
MD5 | f7de6d90956f214da2171f66b395aa2c |
|
BLAKE2b-256 | 523b2266860c3ede99996f1f3e63ec0596d313c1c2d5d34fd93bc33cbc728d5c |