This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

A unittest patch that can automaticly ``skip`` test case based on dependence info calculated by ``trace``.

Project Description

utknows is a unittest patch that can automaticly skip test case based on dependence info calculated by trace.

Installing

You can install utknows through pip or easy-install:

pip install utknows

Or you can download the latest development version, which may contain new features.

Using utknows

utknows should be used before unittest.main is invoked like this:

from utknows import setup_utknows
setup_utknows(db, db_prefix="utknows", root_dir=os.path.abspath(os.curdir))
unittest.main(******, exit=False)
# some resource release, etc db.close()

The db is a persistence database instance, and implementate __getitem__ and __setitem__ method.

The root_dir is the tracing base of dependence used by trace.

The db_prefix is the key prefix in db.

When the first time tests runs, it calculate all the dependence info of every testcase:

utknows/examples$ python alltests.py
......
----------------------------------------------------------------------
Ran 6 tests in 0.031s
OK

After that, the case will be skipped when the dependence info is satisfacted:

utknows/examples$ python alltests.py
ssssss
----------------------------------------------------------------------
Ran 0 tests in 0.003s

OK (skipped=6)

Case will be rerun after you modify any file it depends:

utknows/examples$ touch test_hello.py
utknows/examples$ python alltests.py
...sss
----------------------------------------------------------------------
Ran 3 tests in 0.003s

OK (skipped=3)

The s output here stand for skip.

Examples

Using redis as backend:

import redis

def open_db():
    return redis.Redis(host='localhost', port=6379, db=0)

def close_db(db):
    db.client_kill('localhost:6379')

from utknows import setup_utknows
db = open_db()
setup_utknows(db, root_dir=os.path.abspath(os.curdir))
unittest.main(defaultTest="suite", buffer=True, exit=False)
close_db(db)

Using dbm as backend:

import os
import shelve

def open_db():
    return shelve.open(os.path.join(os.curdir, '.utknows'), writeback=True)

def close_db(db):
    db.sync()
    db.close()

from utknows import setup_utknows
db = open_db()
setup_utknows(db, root_dir=os.path.abspath(os.curdir))
unittest.main(defaultTest="suite", buffer=True, exit=False)
close_db(db)

License

utknows is copyright 2013 mapix and Contributors, and is made available under BSD-style license; see LICENSE for details.

Release History

Release History

This version
History Node

0.1.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
utknows-0.1.1.tar.gz (2.9 kB) Copy SHA256 Checksum SHA256 Source Nov 22, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting