Created
December 14, 2010 18:36
-
-
Save gabrielfalcao/740838 to your computer and use it in GitHub Desktop.
Nose Runner runs tests for django apps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Copyright (C) <2010> Gabriel Falcão <[email protected]> | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You should have received a copy of the GNU General Public License | |
# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
import os | |
import sys | |
import nose | |
from django.conf import settings | |
curdir = os.path.abspath(os.path.dirname(__file__)) | |
def run_tests(test_labels, verbosity=2, interactive=True, extra_tests=[]): | |
# Pretend it's a production environment. | |
settings.DEBUG = False | |
nose_argv = [ | |
'nosetests', '-s', '--verbosity=2', '--exe', '--with-coverage', '--cover-inclusive' | |
] | |
package = os.path.split(os.path.dirname(__file__))[-1] | |
app_names = [app for app in settings.INSTALLED_APPS if not app.startswith("django") and app != 'lettuce.django'] | |
nose_argv.extend(map(lambda name: "--cover-package=%s" % name, app_names)) | |
nose_argv.extend(map(lambda name: "--cover-package=%s.%s" % (package, name), app_names)) | |
# no logging, please | |
nose_argv.append('--nologcapture') | |
if sys.argv[-1] in ('unit', 'functional', 'integration'): | |
kind = sys.argv[-1] | |
apps = map(lambda app: "%s/tests/%s" % (app, kind), app_names) | |
else: | |
apps = app_names | |
nose_argv.extend(apps) | |
try: | |
# cleaning coverage report, because unit and functional | |
# targets could get confused in between test runs | |
os.remove(os.path.join(curdir, '.coverage')) | |
except: | |
pass | |
nose.run(argv=nose_argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment