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
Expand Up @@ -9,26 +9,30 @@ def usage():
print 'run_tests.py APP [node args]'
sys.exit(1)

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

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

argv.append(appdir)

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

environ['DJANGO_SETTINGS_MODULE'] = settings

if not path.isdir(appdir) or not path.exists(settings + '.py'):
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(
argv=argv,
defaultTest=path.abspath(path.dirname(__file__))
Expand Down

0 comments on commit d3eb89d

Please sign in to comment.