Skip to content

Commit

Permalink
saner test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
honzakral committed Jan 1, 2012
1 parent 6ee06fa commit d3eb89d
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions tests/run_tests.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,26 +9,30 @@ def usage():
print 'run_tests.py APP [node args]' print 'run_tests.py APP [node args]'
sys.exit(1) sys.exit(1)


def run_test(app, argv=None): def run_test(app, argv):
for p in ('--with-coverage', '--cover-package=haystack', '--cover-erase'):
if p not in argv:
argv.append(p)


appdir = app appdir = app
settings = 'settings'
if not path.isdir(appdir): if not path.isdir(appdir):
appdir += '_tests' appdir += '_tests'


argv.append(appdir) settings = 'settings'

if path.exists('%s_settings.py' % app): if path.exists('%s_settings.py' % app):
settings = '%s_settings' % app settings = '%s_settings' % app


environ['DJANGO_SETTINGS_MODULE'] = settings

if not path.isdir(appdir) or not path.exists(settings + '.py'): if not path.isdir(appdir) or not path.exists(settings + '.py'):
usage() usage()


environ['DJANGO_SETTINGS_MODULE'] = settings

# only tell nose to run the app tests if the user hasn't specified a test to run
if len(argv) == 1 or not any(not a.startswith('-') for a in argv[1:]):
argv.append(appdir)

for p in ('--with-coverage', '--cover-package=haystack', '--cover-erase'):
if p not in argv:
argv.append(p)


nose.run_exit( nose.run_exit(
argv=argv, argv=argv,
defaultTest=path.abspath(path.dirname(__file__)) defaultTest=path.abspath(path.dirname(__file__))
Expand Down

0 comments on commit d3eb89d

Please sign in to comment.