Giter Site home page Giter Site logo

test-helpers's Introduction

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()

Tornado-related Extensions

The Test Helpers library includes a number of helpers specific to testing Tornado-based applications. Before you can use any of the Tornado helpers, you must either:

  1. install Tornado as a dependency OR
  2. include a dependency on test_helpers[tornado] in your pip requirements

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:

$ 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.