skip to navigation
skip to content

testtube 0.2.0

Testtube watches a specified directory for file changes and runs a set of defined tests against those files whenever a change occurs.

Latest Version: 1.0.0

# Testtube [![Build Status](](

Spare your alt and tab keys by automatically running your project's test suite
whenever files change.

Testtube uses [watchdog]( to monitor
a given path for file changes. It could fairly be described as a simpler
(read: easier to use) implementation of watchdog's included "watchmedo"

## Installation

Install testtube like you'd install any other python package:

pip install testtube

## Usage

### Configure testtube

The simplest way to configure testtube is to drop a file in whatever
directory you'll be running `stir` from. The only thing that needs to be
in that file is a list of tuples named `PATTERNS` consisting of a regular
expression and a list of tests to run.

Here's an example:

from testtube.helpers import pep8_all, pyflakes_all, nosetests_all

(r'.*\.py', [pep8_all, pyflakes_all, nosetests_all]),

Given the configuration above, testtube will match the full path to the
changed file against `r'.*\.py'`. If it matches, it will then run the
following tests: `pep8_all`, `pyflakes_all`, `nosetests_all`.

Testtube comes with a number of helpers, which you can find in
They are designed to save you from writing your own tests as much
as possible. If they don't meet your needs, see the "Writing your own tests"
section below.

### Stir it

> stir
testtube is now watching /Path/to/CWD/ for changes...

By default, stir will watch your current working directory and configure
itself with a settings module named `tube` ( If you dropped a
file into your project root, then you shouldn't need to specify any parameters
assuming you execute stir from that directory. If you've customized things a
bit, `stir -h` will light the way:

usage: stir [-h] [--src_dir SRC_DIR] [--settings SETTINGS]

Watch a directory and run a custom set of tests whenever a file changes.

optional arguments:
-h, --help show this help message and exit
--src_dir SRC_DIR The directory to watch for changes. (Defaults to
--settings SETTINGS The testtube settings module that defines which
tests to run. (Defaults to "tube" - the settings
module must be importable from your current working

### Writing your own tests
If the included helpers don't do what you need, you can write your own tests
right in your settings module. Simply define a callable that accepts at least
one argument and add it to your patterns list:

def mytest(changed_file):
print "Oh snap, %s just changed" % changed_file

(r'.*', [mytest]),

Fortunately, tests can be a bit more clever than that. If you define it like
the following, testtube will pass it all of the named sub patterns in your
regular expression:

def mysmartertest(changed_file, **kwargs):
print "%s in %s/ changed." % (changed_file, kwargs['dir'])

(r'.*/(?P<dir>[^/]*)/.*\.py', [mysmartertest]),

## Everything else

Copyright (c) [Thomas Welfley]( See
[LICENSE]( for
File Type Py Version Uploaded on Size
testtube-0.2.0.tar.gz (md5) Source 2014-04-06 6KB
  • Downloads (All Versions):
  • 7 downloads in the last day
  • 49 downloads in the last week
  • 391 downloads in the last month