def runtests(*test_args): if not test_args: test_args = ['djutils', 'dashboard'] parent = dirname(abspath(__file__)) sys.path.insert(0, parent) failures = run_tests(test_args, verbosity=1, interactive=True) sys.exit(failures)
def runtests(*test_args): if not test_args: test_args = ['pro', 'standard', 'ipn'] parent = dirname(abspath(__file__)) sys.path.insert(0, parent) failures = run_tests(test_args, verbosity=1, interactive=True) sys.exit(failures)
def runtests(*test_args): if not test_args: test_args = ['nexus_celery'] parent = dirname(abspath(__file__)) sys.path.insert(0, parent) failures = run_tests(test_args, verbosity=1, interactive=True) sys.exit(failures)
def runtests(): failures = run_tests([ 'rulez.BackendTest', # 'django_rules.RulePermissionTest', 'rulez.UtilsTest', ], verbosity=1, interactive=True) sys.exit(failures)
def runtests(*test_args): if not test_args: test_args = ['tests'] ROOT = os.path.join(dirname(os.path.abspath(__file__)), '..', '..', '..') path = lambda *a: os.path.join(ROOT, *a) prev_sys_path = list(sys.path) site.addsitedir(path('apps')) site.addsitedir(path('lib')) site.addsitedir(path('vendor')) # Move the new items to the front of sys.path. new_sys_path = [] for item in list(sys.path): if item not in prev_sys_path: new_sys_path.append(item) sys.path.remove(item) sys.path[:0] = new_sys_path parent = os.path.join( os.path.dirname(os.path.abspath(__file__)), "..", "..", ) sys.path.insert(0, parent) failures = run_tests(test_args, verbosity=1, interactive=True) sys.exit(failures)
def runtests(*test_args): if not test_args: test_args = ['sentry'] parent = dirname(abspath(__file__)) sys.path.insert(0, parent) failures = run_tests(test_args, verbosity=1, interactive=True) sys.exit(failures)
def runtests(*test_args): if not test_args: test_args = ('registration',) if twitter is not None: test_args += ( 'twitter', ) if openid_ is not None: test_args += ( 'openid', ) setup_test_environment() parent = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, parent) try: from django.test.simple import DjangoTestSuiteRunner def run_tests(test_args, verbosity, interactive): runner = DjangoTestSuiteRunner( verbosity=verbosity, interactive=interactive, failfast=False) return runner.run_tests(test_args) except ImportError: # for Django versions that don't have DjangoTestSuiteRunner from django.test.simple import run_tests failures = run_tests(test_args, verbosity=1, interactive=True) sys.exit(failures)
def runtests(): failures = run_tests([ 'uni_form.TestBasicFunctionalityTags', 'uni_form.TestFormHelpers', 'uni_form.TestFormLayout', ], verbosity=1, interactive=True) sys.exit(failures)
def runtests(*test_args): if not test_args: test_args = ['tests'] ROOT = os.path.join( dirname(os.path.abspath(__file__)), '..', '..', '..' ) path = lambda *a: os.path.join(ROOT, *a) prev_sys_path = list(sys.path) site.addsitedir(path('apps')) site.addsitedir(path('lib')) site.addsitedir(path('vendor')) # Move the new items to the front of sys.path. new_sys_path = [] for item in list(sys.path): if item not in prev_sys_path: new_sys_path.append(item) sys.path.remove(item) sys.path[:0] = new_sys_path parent = os.path.join( os.path.dirname(os.path.abspath(__file__)), "..", "..", ) sys.path.insert(0, parent) failures = run_tests(test_args, verbosity=1, interactive=True) sys.exit(failures)
def _run_tests(*test_args): if not test_args: test_args = ['honey'] parent = path.join(path.dirname(path.abspath(__file__)), "../../") sys.path.insert(0, parent) failures = run_tests(test_args, verbosity=1, interactive=True) sys.exit(failures)
def run(): import sys from django.conf import settings from django.test.simple import run_tests failures = run_tests(['extracontent'], verbosity=1) if failures: sys.exit(failures)
def _old_tests(self): """ Fire up the Django test suite from before version 1.2 """ settings.configure(DEBUG = True, DATABASE_ENGINE = 'sqlite3', DATABASE_NAME = os.path.join(self.DIRNAME, 'database.db'), INSTALLED_APPS = self.INSTALLED_APPS + self.apps, ROOT_URLCONF = 'staticshard.tests.urls', STATIC_URL = 'http://domain.example.com/static/', STATICFILES_STORAGE = 'staticshard.storage.StaticShardFilesStorage', STATICSHARD_HOSTS = [ 'domain-01.example.com', 'domain-02.example.com', 'domain-03.example.com', 'domain-04.example.com' ], MIDDLEWARE_CLASSES = ( 'staticshard.middleware.StaticShardMiddleware' ), ) from django.test.simple import run_tests failures = run_tests(self.apps, verbosity=1) if failures: sys.exit(failures)
def runtests(*test_args): if not test_args: test_args = ['bitfield'] parent = dirname(abspath(__file__)) sys.path.insert(0, parent) failures = run_tests(test_args, verbosity=1, interactive='--no-input' not in sys.argv) sys.exit(failures)
def runtests(*test_args): if not test_args: test_args = ['tests'] parent = os.path.join(TEST_DIR, "..", "..") sys.path.insert(0, parent) failures = run_tests(test_args, verbosity=1, interactive=True) sys.exit(failures)
def runtests(*test_args): if not test_args: test_args = ['completion_tests'] ac_dir = os.path.join(os.path.dirname(__file__), 'completion') sys.path.insert(0, ac_dir) failures = run_tests(test_args, verbosity=1, interactive=True) sys.exit(failures)
def run_tests(test_labels, verbosity=1, interactive=True, extra_tests=[]): coverage.start() test_results = simple.run_tests(test_labels, verbosity, interactive, extra_tests) coverage.stop() # Test only own code and make its coverage if verbosity >= 1: print "Generating coverage report..." coverage_modules = [] for app in test_labels: try: module = __import__(app, globals(), locals(), ['']) except ImportError: coverage_modules = None break if module: base_path = os.path.join(os.path.split(module.__file__)[0], "") # Find non-empty .py files for root, dirs, files in os.walk(base_path): for fname in files: if fname.endswith(".py") and os.path.getsize(os.path.join(root, fname)) > 1: try: mname = os.path.join(app, os.path.join(root, fname).replace(base_path, "")) coverage_modules.append(mname) except ImportError: pass #do nothing # Building html-report if coverage_modules or not test_labels: coverage.html_report(coverage_modules, directory=settings.COVERAGE_REPORT_PATH) return test_results
def runtests(*test_args): if not test_args: test_args = ['sophie'] parent = dirname(abspath(__file__)) sys.path.insert(0, parent) failures = run_tests(test_args, verbosity=1) sys.exit(failures)
def runtests(*test_args): parent = dirname(abspath(__file__)) sys.path.insert(0, parent) try: from django.test.runner import DiscoverRunner def run_tests(test_args, verbosity, interactive): runner = DiscoverRunner( verbosity=verbosity, interactive=interactive, failfast=False) return runner.run_tests(test_args) except ImportError: if not test_args: test_args = ['tests'] try: from django.test.simple import DjangoTestSuiteRunner def run_tests(test_args, verbosity, interactive): runner = DjangoTestSuiteRunner( verbosity=verbosity, interactive=interactive, failfast=False) return runner.run_tests(test_args) except ImportError: from django.test.simple import run_tests failures = run_tests( test_args, verbosity=1, interactive=True) sys.exit(failures)
def runtests(): verbose_level = 1 args = sys.argv[1:] if '-v' in args: index = args.index('-v') _ = args.pop(index) verbose_level = int(args.pop(index)) if args: test_labels = ["model_mommy.%s" % arg for arg in args] else: test_labels = ['model_mommy'] try: from django.test.simple import run_tests result = run_tests(test_labels, verbose_level, True) sys.exit(result) except ImportError: from django.test.simple import DjangoTestSuiteRunner test_suite = DjangoTestSuiteRunner(verbose_level, True) result = test_suite.run_tests(test_labels) sys.exit(result)
def runtests(*test_args): parent = dirname(abspath(__file__)) sys.path.insert(0, parent) try: from django.test.runner import DiscoverRunner def run_tests(test_args, verbosity, interactive): runner = DiscoverRunner(verbosity=verbosity, interactive=interactive, failfast=False) return runner.run_tests(test_args) except ImportError: if not test_args: test_args = ['tests'] try: from django.test.simple import DjangoTestSuiteRunner def run_tests(test_args, verbosity, interactive): runner = DjangoTestSuiteRunner(verbosity=verbosity, interactive=interactive, failfast=False) return runner.run_tests(test_args) except ImportError: from django.test.simple import run_tests failures = run_tests(test_args, verbosity=1, interactive=True) sys.exit(failures)
def runtests(*test_args): if not test_args: test_args = ["dialogos"] parent = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, parent) failures = run_tests(test_args, verbosity=1, interactive=True) sys.exit(failures)
def runtests(*test_args): if not test_args: test_args = ["agon"] parent = dirname(abspath(__file__)) sys.path.insert(0, parent) from django.test.simple import run_tests failures = run_tests(test_args, verbosity=1, interactive=True) sys.exit(failures)
def runtests(*args): if not args: args = ['tests'] sys.path.insert(0, os.path.dirname(TEST_ROOT)) sys.path.insert(0, os.path.dirname(os.path.dirname(TEST_ROOT))) failures = run_tests(args, verbosity=1, interactive=True) sys.exit(failures)
def runtests(*args): failures = run_tests(args or [ 'django_mobile', 'django_mobile_tests', ], verbosity=1, interactive=True) sys.exit(failures)
def runtests(*args): failures = run_tests( args or [ 'pandora', 'pandora_tests', ], verbosity=1, interactive=True) sys.exit(failures)
def _old_tests(self, verbosity=1, interactive=False, extra_tests=[], **kwargs): """ Fire up the Django test suite from before version 1.2 """ settings.configure(DEBUG=True, DATABASE_ENGINE='sqlite3', INSTALLED_APPS=self.INSTALLED_APPS + self.apps, ROOT_URLCONF=__name__) self._setup_urlpatterns() from django.test.simple import run_tests return run_tests(self.apps, verbosity=verbosity, interactive=interactive, extra_tests=extra_tests)
def runtests(): failures = run_tests([ 'django_rules.BackendTest', 'django_rules.RulePermissionTest', 'django_rules.UtilsTest', 'django_rules.DecoratorsTest' ], verbosity=1, interactive=True) sys.exit(failures)
def runtests(*args): failures = run_tests( args or [ 'appname', 'appname_tests', ], verbosity=1, interactive=True) sys.exit(failures)
def runtests(*args): failures = run_tests( args or [ 'django_mobile', 'django_mobile_tests', ], verbosity=1, interactive=True) sys.exit(failures)
def runtests(*args): failures = run_tests(args or [ 'pandora', 'pandora_tests', ], verbosity=1, interactive=True) sys.exit(failures)
def runtests(*args): failures = run_tests( args or [ 'ichypd', 'ichypd_tests', ], verbosity=1, interactive=True) sys.exit(failures)
def runtests(*test_args): if not test_args: test_args = ["mediagal"] parent = dirname(abspath(__file__)) sys.path.insert(0, parent) from django.test.simple import run_tests failures = run_tests(test_args, verbosity=1, interactive=True) sys.exit(failures)
def run_tests(test_labels, verbosity=1, interactive=True, extra_tests=[]): total_tests = simple.run_tests(test_labels, verbosity, interactive, extra_tests) print >>sys.stdout print >>sys.stdout, 'Tested the following:' for t in Register.tested: print >>sys.stdout, ' * %s' %t return total_tests
def runtests(*test_args): if not test_args: test_args = ['shop_simplecategories'] parent = os.path.join( os.path.dirname(os.path.abspath(__file__)), "..", "..") sys.path.insert(0, parent) failures = run_tests(test_args, verbosity=1, interactive=True) sys.exit(failures)
def runtests(*test_args): if not test_args: test_args = ['shop_simplecategories'] parent = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..") sys.path.insert(0, parent) failures = run_tests(test_args, verbosity=1, interactive=True) sys.exit(failures)
def runtests(*test_labels): test_labels = test_labels or [ 'mockups', 'generator_test', 'mockups_test', ] sys.path.insert(0, pjoin(TEST_ROOT, pardir, pardir)) failures = run_tests(test_labels, verbosity=1, interactive=True) sys.exit(failures)
def runtests(*test_args, **kwargs): if 'south' in settings.INSTALLED_APPS: from south.management.commands import patch_for_test_db_setup patch_for_test_db_setup() if not test_args: test_args = ['attachments'] failures = run_tests(test_args, verbosity=kwargs.get('verbosity', 1), interactive=kwargs.get('interactive', False), failfast=kwargs.get('failfast')) sys.exit(failures)
def _old_tests(self): settings.configure(DEBUG = True, DATABASE_ENGINE = 'sqlite3', DATABASE_NAME = os.path.join(self.DIRNAME, 'database.db), INSTALLED_APPS = self.INSTALLED_APPS + self.apps ) from django.test.simple import run_tests failures = run_tests(self.apps, verbosity=1) if failures: sys.exit(failures)
def run_tests(test_labels, verbosity=1, interactive=True, extra_tests=[]): '''Sets up the environment and runs tests for django-baseboard.''' establish_settings() from django.test.simple import run_tests failures = run_tests(test_labels, verbosity=verbosity, interactive=interactive, extra_tests=extra_tests) if failures: sys.exit(failures) restore_settings()
def run_tests(test_labels, verbosity=1, interactive=True, extra_tests=[]): """ Run the unit tests for all the test labels in the provided list. Labels must be of the form: - app.TestClass.test_method Run a single specific test method - app.TestClass Run all the test methods in a given class - app Search for doctests and unittests in the named application. When looking for tests, the test runner will look in the models and tests modules for the application. A list of 'extra' tests may also be provided; these tests will be added to the test suite. If the settings file has an entry for COVERAGE_MODULES or test_labels is true it will prints the coverage report for modules/apps Returns number of tests that failed. """ do_coverage = hasattr(settings, 'COVERAGE_MODULES') or bool(test_labels) if do_coverage: coverage.erase() coverage.start() from django.test import simple retval = simple.run_tests(test_labels, verbosity, interactive, extra_tests) if do_coverage: coverage.stop() # Print code metrics header print '' print '----------------------------------------------------------------------' print ' Unit Test Code Coverage Results' print '----------------------------------------------------------------------' # try to import all modules for the coverage report. modules = [] if getattr(settings, 'COVERAGE_MODULES', None): modules = [__import__(module, {}, {}, ['']) for module in settings.COVERAGE_MODULES] elif test_labels: modules = [] for label in test_labels: label = label.split('.')[0] #remove test class or test method from label pkg = _get_app_package(label) modules.extend(_package_modules(*pkg)) coverage.report(modules, show_missing=1) return retval
def runtests(*test_args): if 'south' in settings.INSTALLED_APPS: from south.management.commands import patch_for_test_db_setup patch_for_test_db_setup() if not test_args: test_args = ['sentry'] parent = dirname(abspath(__file__)) sys.path.insert(0, parent) failures = run_tests(test_args, verbosity=1, interactive=True) sys.exit(failures)
def runtests(*test_args, **kwargs): if 'south' in settings.INSTALLED_APPS: from south.management.commands import patch_for_test_db_setup patch_for_test_db_setup() if not test_args: test_args = ['tests'] parent = dirname(abspath(__file__)) sys.path.insert(0, parent) failures = run_tests(test_args, verbosity=kwargs.get('verbosity', 1), interactive=kwargs.get('interactive', False), failfast=kwargs.get('failfast')) sys.exit(failures)
def runtests(*test_args): if 'south' in settings.INSTALLED_APPS: from south.management.commands import patch_for_test_db_setup patch_for_test_db_setup() if not test_args: test_args = ['ticketing'] parent = dirname(abspath(__file__)) sys.path.insert(0, parent) failures = run_tests(test_args, verbosity=0, interactive=True) sys.exit(failures)
def runtests(*test_args): if not test_args: test_args = ['debug_toolbar_htmltidy'] parent = os.path.join( os.path.dirname(os.path.abspath(__file__)), "..", #"..", ) sys.path.insert(0, parent) failures = run_tests(test_args, verbosity=2, interactive=True) sys.exit(failures)
def runtests(*args): failures = run_tests( args or [ 'autofixture', 'autofixture_tests', 'autofixture_test', 'generator_test', 'values_tests', 'sample_app', ], verbosity=1, interactive=True) sys.exit(failures)
def runtests(*test_args): if not test_args: test_args = ['tests'] sys.path.insert(0, DIRNAME) os.environ['DJANGO_SETTINGS_MODULE'] = 'versions.tests.settings' log = logging.getLogger('versions') handler = logging.handlers.MemoryHandler(1000) log.addHandler(handler) from django.test.simple import run_tests failures = run_tests(test_args, verbosity=1, interactive=True) sys.exit(failures)
def runtests(*test_args, **kwargs): if 'south' in settings.INSTALLED_APPS: from south.management.commands import patch_for_test_db_setup patch_for_test_db_setup() if not test_args: test_args = ['contact_form'] failures = run_tests(test_args, verbosity=kwargs.get('verbosity', 1), interactive=kwargs.get('interactive', False), failfast=kwargs.get('failfast')) sys.exit(failures)
def _old_tests(self): """ Fire up the Django test suite from before version 1.2 """ settings.configure(DEBUG = True, DATABASE_ENGINE = 'sqlite3', DATABASE_NAME = os.path.join(self.DIRNAME, 'database.db'), INSTALLED_APPS = self.INSTALLED_APPS + self.apps, ROOT_URLCONF = 'unfriendly.tests.urls', ) from django.test.simple import run_tests failures = run_tests(self.apps, verbosity=1) if failures: sys.exit(failures)
def _old_tests(self): """ Fire up the Django test suite from before version 1.2 """ settings.configure(DEBUG=True, DATABASE_ENGINE='sqlite3', DATABASE_NAME=os.path.join(self.DIRNAME, 'database.db'), INSTALLED_APPS=self.INSTALLED_APPS + self.apps, TEST_RUNNER='django.contrib.gis.tests.run_tests') from django.test.simple import run_tests failures = run_tests(self.apps, verbosity=1) if failures: sys.exit(failures)
def runtests(): args = sys.argv[1:] if args: test_labels = ["model_mommy.%s" % arg for arg in args] else: test_labels = ['model_mommy'] try: from django.test.simple import run_tests result = run_tests(test_labels, 1, True) sys.exit(result) except ImportError: from django.test.simple import DjangoTestSuiteRunner test_suite = DjangoTestSuiteRunner(1, True) result = test_suite.run_tests(test_labels) sys.exit(result)
def run(*args, **kwargs): override_settings_for_testing() try: if os.environ.get('USER', 'unknown') == 'hudson': # Hudson should run with xmlrunner because he consumes # JUnit-style xml test reports. return xmlrunner.extra.djangotestrunner.run_tests(*args, **kwargs) else: # Those of us unfortunate enough not to have been born # Hudson should use the normal test runner, because # xmlrunner swallows input, preventing interaction with # pdb.set_trace(), which makes debugging a pain! return run_tests(*args, **kwargs) finally: cleanup_after_tests()
def _tests_old(self): """ Fire up the Django test suite from before version 1.2 """ INSTALLED_APPS, settings_test = self.get_custom_settings() settings.configure( DEBUG=True, DATABASE_ENGINE='sqlite3', DATABASE_NAME=os.path.join(self.DIRNAME, 'database.db'), INSTALLED_APPS=self.INSTALLED_APPS + INSTALLED_APPS + self.apps, **settings_test) from django.test.simple import run_tests failures = run_tests(self.apps, verbosity=1) if failures: sys.exit(failures)
def _old_tests(self): """ Fire up the Django test suite from before version 1.2 """ settings.configure( DEBUG=True, DATABASE_ENGINE='sqlite3', DATABASE_NAME=os.path.join(self.DIRNAME, 'database.db'), INSTALLED_APPS=self.INSTALLED_APPS + self.apps, FACEBOOK_REALTIME_VERIFY_TOKEN= 'EJEgWVcZCyx7NNoKT83xbxrKPy0sQPYZBZCkEZAm31PPoOoHojlTHPhGgZDAA', ROOT_URLCONF='urlstest') from django.test.simple import run_tests failures = run_tests(self.apps, verbosity=1) if failures: sys.exit(failures)
def _tests_old(self): """ Fire up the Django test suite from before version 1.2 """ test_settings = self.custom_settings installed_apps = test_settings.pop('INSTALLED_APPS', ()) settings.configure(DEBUG=True, DATABASE_ENGINE='sqlite3', DATABASE_NAME=os.path.join(self.DIRNAME, 'database.db'), INSTALLED_APPS=tuple(self.INSTALLED_APPS + installed_apps + self.apps), **test_settings) from django.test.simple import run_tests failures = run_tests(self.apps, verbosity=1) if failures: sys.exit(failures)
def run_tests(test_labels, verbosity=1, interactive=True, extra_tests=[]): # часть непосредственно отвечающая за получение данных о покрытии (включить сбор; выполнить тесты; выключить сбор) coverage.start() test_results = simple.run_tests(test_labels, verbosity, interactive, extra_tests) coverage.stop() # Как известно, manage.py test может не все тесты, а только из определенных приложений # немного не логично, что в этом случае покрытие будет определено для всего кода в проекте # и для не ваших приложений и для библиотек. # Следующий код берет имена приложений для тестирования из test_labels, определяет все модули # входящие в их состав и передает список для построения отчета. # Это очень удобно, мы тестируем только свой код и получаем только его покрытие. coverage_modules = [] for app in test_labels: try: module = __import__(app, globals(), locals(), ['']) except ImportError: # Эта ситуация возникает в случае если тестирование ограничено одним TestCase, либо модуль недоступен # В обоих случая нам не нужен отчет о покрытии. coverage_modules = None break if module: base_path = os.path.join(os.path.split(module.__file__)[0], "") # Ищем внутри приложения непустые .py файлы for root, dirs, files in os.walk(base_path): for fname in files: if fname.endswith(".py") and os.path.getsize( os.path.join(root, fname)) > 1: try: mname = os.path.join( app, os.path.join(root, fname).replace(base_path, "")) coverage_modules.append(mname) except ImportError: pass #do nothing # Строим html-отчет if coverage_modules or not test_labels: coverage.html_report(coverage_modules, directory=settings.COVERAGE_REPORT_PATH) return test_results