本文整理汇总了Python中django.test.utils.get_runner方法的典型用法代码示例。如果您正苦于以下问题:Python utils.get_runner方法的具体用法?Python utils.get_runner怎么用?Python utils.get_runner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.test.utils
的用法示例。
在下文中一共展示了utils.get_runner方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runtests
# 需要导入模块: from django.test import utils [as 别名]
# 或者: from django.test.utils import get_runner [as 别名]
def runtests():
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.test_settings'
django.setup()
TestRunner = get_runner(settings)
test_runner = TestRunner()
# By default, run all of the tests
tests = ['tests']
# Allow running a subset of tests via the command line.
if len(sys.argv) > 1:
tests = sys.argv[1:]
failures = test_runner.run_tests(tests, verbosity=3)
if failures:
sys.exit(failures)
示例2: run_tests
# 需要导入模块: from django.test import utils [as 别名]
# 或者: from django.test.utils import get_runner [as 别名]
def run_tests(self):
import django
django.setup()
from django.conf import settings
from django.test.utils import get_runner
TestRunner = get_runner(settings, self.testrunner)
test_runner = TestRunner(
pattern=self.pattern,
top_level=self.top_level_directory,
verbosity=self.verbose,
interactive=(not self.noinput),
failfast=self.failfast,
keepdb=self.keepdb,
reverse=self.reverse,
debug_sql=self.debug_sql,
output_dir=self.output_dir)
failures = test_runner.run_tests(self.test_labels)
sys.exit(bool(failures))
示例3: run_tests_coverage
# 需要导入模块: from django.test import utils [as 别名]
# 或者: from django.test.utils import get_runner [as 别名]
def run_tests_coverage():
if __name__ == "__main__":
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
django.setup()
TestRunner = get_runner(settings)
test_runner = TestRunner()
# Setup Coverage
cov = coverage(source=["rest_framework_docs"], omit=["rest_framework_docs/__init__.py"])
cov.start()
failures = test_runner.run_tests(["tests"])
if bool(failures):
cov.erase()
sys.exit("Tests Failed. Coverage Cancelled.")
# If success show coverage results
cov.stop()
cov.save()
cov.report()
cov.html_report(directory='covhtml')
示例4: run_tests
# 需要导入模块: from django.test import utils [as 别名]
# 或者: from django.test.utils import get_runner [as 别名]
def run_tests():
# Making Django run this way is a two-step process. First, call
# settings.configure() to give Django settings to work with:
from django.conf import settings
settings.configure(**SETTINGS_DICT)
# Then, call django.setup() to initialize the application registry
# and other bits:
import django
django.setup()
# Now we instantiate a test runner...
from django.test.utils import get_runner
TestRunner = get_runner(settings)
# And then we run tests and return the results.
test_runner = TestRunner(verbosity=2, interactive=True)
failures = test_runner.run_tests(["tests"])
sys.exit(failures)
示例5: run
# 需要导入模块: from django.test import utils [as 别名]
# 或者: from django.test.utils import get_runner [as 别名]
def run():
"""Run tests with Django setup."""
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
from django.conf import settings
# Will only work in 1.7
try:
from django import setup
except ImportError:
pass
else:
setup()
from django.test.utils import get_runner
TestRunner = get_runner(settings)
test_runner = TestRunner()
failures = test_runner.run_tests(["tests"])
sys.exit(bool(failures))
示例6: run_tests
# 需要导入模块: from django.test import utils [as 别名]
# 或者: from django.test.utils import get_runner [as 别名]
def run_tests():
# First configure settings, then call django.setup() to initialise
from django.conf import settings
settings.configure(**SETTINGS_DICT)
import django
django.setup()
# Now create the test runner
from django.test.utils import get_runner
TestRunner = get_runner(settings)
# And then we run tests and return the results.
test_runner = TestRunner(verbosity=2, interactive=True)
failures = test_runner.run_tests(["tests"])
sys.exit(failures)
示例7: main
# 需要导入模块: from django.test import utils [as 别名]
# 或者: from django.test.utils import get_runner [as 别名]
def main():
TestRunner = get_runner(settings)
test_runner = TestRunner()
if len(sys.argv) == 2:
test_case = sys.argv[1]
elif len(sys.argv) == 1:
test_case = 'tests'
else:
print(usage())
sys.exit(1)
test_module_name = 'drf_to_s3.'
if django.VERSION[0] == 1 and django.VERSION[1] < 6:
test_module_name = ''
failures = test_runner.run_tests([test_module_name + test_case])
sys.exit(failures)
示例8: run_tests
# 需要导入模块: from django.test import utils [as 别名]
# 或者: from django.test.utils import get_runner [as 别名]
def run_tests(*args, **kwargs):
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
django.setup()
TestRunner = get_runner(settings)
test_runner = TestRunner(**kwargs)
failures = test_runner.run_tests(args)
try:
os.remove('./celerybeat-schedule.bak')
except Exception:
pass
try:
os.remove('./celerybeat-schedule.dat')
except Exception:
pass
try:
os.remove('./celerybeat-schedule.dir')
except Exception:
pass
sys.exit(bool(failures))
示例9: handle
# 需要导入模块: from django.test import utils [as 别名]
# 或者: from django.test.utils import get_runner [as 别名]
def handle(self, *test_labels, **options):
from django.conf import settings
from django.test.utils import get_runner
TestRunner = get_runner(settings, options.get('testrunner'))
options['verbosity'] = int(options.get('verbosity'))
if options.get('liveserver') is not None:
os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = options['liveserver']
del options['liveserver']
test_runner = TestRunner(**options)
failures = test_runner.run_tests(test_labels)
if failures:
sys.exit(bool(failures))
示例10: runtests
# 需要导入模块: from django.test import utils [as 别名]
# 或者: from django.test.utils import get_runner [as 别名]
def runtests():
"""
The test runner for setup.py test usage. This sets up
a memory database with sqlite3 and runs the tests via
the django test command.
"""
from conf import settings
settings = settings(
DATABASE_ENGINE='sqlite3',
DATABASE_NAME=':memory:',
)
from django.test.utils import get_runner
test_runner = get_runner(settings)
failures = test_runner([], verbosity=1, interactive=True)
raise SystemExit(failures)
示例11: main
# 需要导入模块: from django.test import utils [as 别名]
# 或者: from django.test.utils import get_runner [as 别名]
def main():
settings.configure(
ROOT_URLCONF='wsrequest.tests',
INSTALLED_APPS=[
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
],
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'db.sqlite3',
}
}
)
from django.test.utils import get_runner
test_runner = get_runner(settings)(verbosity=1, interactive=True)
failures = test_runner.run_tests(['wsrequest.tests'])
sys.exit(failures)
示例12: make_test_runner
# 需要导入模块: from django.test import utils [as 别名]
# 或者: from django.test.utils import get_runner [as 别名]
def make_test_runner(verbosity, interactive, failfast, keepdb, reverse,
debug_sql, parallel, tags, exclude_tags):
if not hasattr(settings, 'TEST_RUNNER'):
settings.TEST_RUNNER = 'django.test.runner.DiscoverRunner'
TestRunner = get_runner(settings)
test_runner = TestRunner(
verbosity=verbosity,
interactive=interactive,
failfast=failfast,
keepdb=keepdb,
reverse=reverse,
debug_sql=debug_sql,
parallel=actual_test_processes(parallel),
tags=tags,
exclude_tags=exclude_tags,
)
return test_runner
示例13: runDjangoTest
# 需要导入模块: from django.test import utils [as 别名]
# 或者: from django.test.utils import get_runner [as 别名]
def runDjangoTest():
cleanMedia()
verbosity = 1
if "-v" in sys.argv or "--verbose" in sys.argv:
verbosity = 2
django.setup()
TestRunner = get_runner(settings)
test_runner = TestRunner(top_level="ls/joyous",
verbosity=verbosity,
keepdb=True)
labels = ["ls.joyous.tests."+arg for arg in sys.argv[1:]
if not arg.startswith("-")]
if not labels:
labels = ["ls.joyous.tests"]
failures = test_runner.run_tests(labels)
return failures
示例14: main
# 需要导入模块: from django.test import utils [as 别名]
# 或者: from django.test.utils import get_runner [as 别名]
def main():
try:
django.setup()
except AttributeError:
pass
TestRunner = get_runner(settings)
test_runner = TestRunner()
if len(sys.argv) == 2:
test_case = '.' + sys.argv[1]
elif len(sys.argv) == 1:
test_case = ''
else:
print(usage())
sys.exit(1)
test_module_name = 'unsubscribe.tests'
if django.VERSION[0] == 1 and django.VERSION[1] < 6:
test_module_name = 'tests'
failures = test_runner.run_tests(
[test_module_name + test_case], verbosity=1, interactive=True)
sys.exit(failures)
示例15: run_tests
# 需要导入模块: from django.test import utils [as 别名]
# 或者: from django.test.utils import get_runner [as 别名]
def run_tests(*test_args):
if not test_args:
test_args = ['tests']
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
django.setup()
TestRunner = get_runner(settings)
test_runner = TestRunner()
failures = test_runner.run_tests(test_args)
sys.exit(bool(failures))