Skip to content

Instantly share code, notes, and snippets.

@markng
Created March 24, 2015 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markng/233222b96e1ae1ca9971 to your computer and use it in GitHub Desktop.
Save markng/233222b96e1ae1ca9971 to your computer and use it in GitHub Desktop.
from sniffer.api import * # import the really small API
import os, termstyle, subprocess
# you can customize the pass/fail colors like this
pass_fg_color = termstyle.green
pass_bg_color = termstyle.bg_default
fail_fg_color = termstyle.red
fail_bg_color = termstyle.bg_default
# All lists in this variable will be under surveillance for changes.
watch_paths = ['.', 'tests/']
# this gets invoked on every file that gets changed in the directory. Return
# True to invoke any runnable functions, False otherwise.
#
# This fires runnables only if files ending with .py extension and not prefixed
# with a period.
@file_validator
def py_files(filename):
return filename.endswith('.py') and not os.path.basename(filename).startswith('.')
# This gets invoked for verification. This is ideal for running tests of some sort.
# For anything you want to get constantly reloaded, do an import in the function.
#
# sys.argv[0] and any arguments passed via -x prefix will be sent to this function as
# it's arguments. The function should return logically True if the validation passed
# and logicially False if it fails.
#
# This example simply runs nose.
# @runnable
# def execute_nose(*args):
# import nose
# new_args = list(args)
# new_args.append('--with-specplugin')
# new_args.append('--with-specselector')
# print new_args
# return nose.run(argv=new_args)
@runnable
def execute_tests(*args):
subprocess.call('clear')
fn = [ 'python', 'manage.py', 'test', '--with-specselector', '--with-specplugin', '--nologcapture' ]
fn.append('--where=wall/tests')
fn += args[1:]
return subprocess.call(fn) == 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment