diff options
| author | Claude Paroz <claude@2xlibre.net> | 2014-06-06 20:12:23 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2014-06-14 13:43:39 +0200 |
| commit | 4b4524291adbc78ab880317124803fc37a2e414a (patch) | |
| tree | 71e03eadb772e9a4dc1e74c2d00a7465b469ffc1 /tests | |
| parent | cbff097bd91fad42c7231026968f686598b1d7a2 (diff) | |
Converted test management command to argparse
Keeping backwards compatibility with test_runner.option_list is
tricky and would imply transforming an optparse.Option to an
argparse.Action. I choose to introduce a backwards incompatible
change because it only affects testing, not runtime behavior.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_runner/tests.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/test_runner/tests.py b/tests/test_runner/tests.py index 2a9337302f..e0faf77ebf 100644 --- a/tests/test_runner/tests.py +++ b/tests/test_runner/tests.py @@ -3,7 +3,6 @@ Tests for django test runner """ from __future__ import unicode_literals -from optparse import make_option import unittest from django.core.exceptions import ImproperlyConfigured @@ -152,11 +151,6 @@ class ManageCommandTests(unittest.TestCase): class CustomOptionsTestRunner(runner.DiscoverRunner): - option_list = ( - make_option('--option_a', '-a', action='store', dest='option_a', default='1'), - make_option('--option_b', '-b', action='store', dest='option_b', default='2'), - make_option('--option_c', '-c', action='store', dest='option_c', default='3'), - ) def __init__(self, verbosity=1, interactive=True, failfast=True, option_a=None, option_b=None, option_c=None, **kwargs): super(CustomOptionsTestRunner, self).__init__(verbosity=verbosity, interactive=interactive, @@ -165,6 +159,12 @@ class CustomOptionsTestRunner(runner.DiscoverRunner): self.option_b = option_b self.option_c = option_c + @classmethod + def add_arguments(cls, parser): + parser.add_argument('--option_a', '-a', action='store', dest='option_a', default='1'), + parser.add_argument('--option_b', '-b', action='store', dest='option_b', default='2'), + parser.add_argument('--option_c', '-c', action='store', dest='option_c', default='3'), + def run_tests(self, test_labels, extra_tests=None, **kwargs): print("%s:%s:%s" % (self.option_a, self.option_b, self.option_c)) |
