mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
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.
This commit is contained in:
@@ -294,6 +294,17 @@ you don't have to keep compatibility with older Django versions, it's better to
|
||||
implement the new :meth:`~django.core.management.BaseCommand.add_arguments`
|
||||
method as described in :doc:`/howto/custom-management-commands`.
|
||||
|
||||
Custom test management command arguments through test runner
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The method to add custom arguments to the `test` management command through the
|
||||
test runner has changed. Previously, you could provide an `option_list` class
|
||||
variable on the test runner to add more arguments (à la :py:mod:`optparse`).
|
||||
Now to implement the same behavior, you have to create an
|
||||
``add_arguments(cls, parser)`` class method on the test runner and call
|
||||
``parser.add_argument`` to add any custom arguments, as parser is now an
|
||||
:py:class:`argparse.ArgumentParser` instance.
|
||||
|
||||
Miscellaneous
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
Reference in New Issue
Block a user