mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-06-18 12:33:20 +03:00
deleted pre-Django 1.2 work-around and added a usage string.
This commit is contained in:
parent
437a062b6c
commit
49a2817eb5
|
@ -13,25 +13,27 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'djangorestframework.runtests.settings'
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.test.utils import get_runner
|
from django.test.utils import get_runner
|
||||||
|
|
||||||
|
def usage():
|
||||||
|
return """
|
||||||
|
Usage: python runtests.py [UnitTestClass].[method]
|
||||||
|
|
||||||
|
You can pass the Class name of the `UnitTestClass` you want to test.
|
||||||
|
|
||||||
|
Append a method name if you only want to test a specific method of that class.
|
||||||
|
"""
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
TestRunner = get_runner(settings)
|
TestRunner = get_runner(settings)
|
||||||
|
|
||||||
if hasattr(TestRunner, 'func_name'):
|
test_runner = TestRunner()
|
||||||
# Pre 1.2 test runners were just functions,
|
if len(sys.argv) == 2:
|
||||||
# and did not support the 'failfast' option.
|
test_case = '.' + sys.argv[1]
|
||||||
import warnings
|
elif len(sys.argv) == 1:
|
||||||
warnings.warn(
|
test_case = ''
|
||||||
'Function-based test runners are deprecated. Test runners should be classes with a run_tests() method.',
|
|
||||||
DeprecationWarning
|
|
||||||
)
|
|
||||||
failures = TestRunner(['djangorestframework'])
|
|
||||||
else:
|
else:
|
||||||
test_runner = TestRunner()
|
print usage()
|
||||||
if len(sys.argv) > 1:
|
sys.exit(1)
|
||||||
test_case = '.' + sys.argv[1]
|
failures = test_runner.run_tests(['djangorestframework' + test_case])
|
||||||
else:
|
|
||||||
test_case = ''
|
|
||||||
failures = test_runner.run_tests(['djangorestframework' + test_case])
|
|
||||||
|
|
||||||
sys.exit(failures)
|
sys.exit(failures)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user