1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #19973 -- Replaced optparse by argparse in management commands

Thanks Tim Graham for the review.
This commit is contained in:
Claude Paroz
2013-10-16 16:24:59 +02:00
parent 79956d0694
commit 8568638603
8 changed files with 202 additions and 151 deletions

View File

@@ -74,6 +74,24 @@ class CommandTests(SimpleTestCase):
if current_path is not None:
os.environ['PATH'] = current_path
def test_optparse_compatibility(self):
"""
optparse should be supported during Django 1.8/1.9 releases.
"""
out = StringIO()
management.call_command('optparse_cmd', stdout=out)
self.assertEqual(out.getvalue(), "All right, let's dance Rock'n'Roll.\n")
# Simulate command line execution
old_stdout, old_stderr = sys.stdout, sys.stderr
sys.stdout, sys.stderr = StringIO(), StringIO()
try:
management.execute_from_command_line(['django-admin', 'optparse_cmd'])
finally:
output = sys.stdout.getvalue()
sys.stdout, sys.stderr = old_stdout, old_stderr
self.assertEqual(output, "All right, let's dance Rock'n'Roll.\n")
class UtilsTests(SimpleTestCase):