mirror of
https://github.com/jazzband/django-configurations.git
synced 2026-03-16 22:20:27 +00:00
Add a test which demonstrates the optparse fallback issue
This commit is contained in:
parent
cd0f1b4d0c
commit
4fe1c74b35
5 changed files with 36 additions and 0 deletions
0
tests/management/__init__.py
Normal file
0
tests/management/__init__.py
Normal file
0
tests/management/commands/__init__.py
Normal file
0
tests/management/commands/__init__.py
Normal file
16
tests/management/commands/old_optparse_command.py
Normal file
16
tests/management/commands/old_optparse_command.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from optparse import make_option
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
||||
# Used by a specific test to see how unupgraded
|
||||
# management commands play with configurations.
|
||||
# See the test code for more details.
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('--arg1', action='store_true'),
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
pass
|
||||
|
|
@ -6,3 +6,4 @@ dj-email-url
|
|||
dj-search-url
|
||||
django-cache-url>=1.0.0
|
||||
six
|
||||
unittest2
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import unittest2
|
||||
|
||||
from django import VERSION as DJANGO_VERSION
|
||||
from django.conf import global_settings
|
||||
from django.test import TestCase
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
|
@ -108,3 +110,20 @@ class MainTests(TestCase):
|
|||
proc = subprocess.Popen(['django-cadmin', 'runserver', '--help'],
|
||||
stdout=subprocess.PIPE)
|
||||
self.assertIn('--configuration', proc.communicate()[0].decode('utf-8'))
|
||||
|
||||
@unittest2.skipIf(DJANGO_VERSION >= (1, 10), 'only applies to Django < 1.10')
|
||||
def test_deprecated_option_list_command(self):
|
||||
"""
|
||||
Verify that the configuration option is correctly added to any
|
||||
management commands which are still relying on option_list to
|
||||
add their own custom arguments
|
||||
|
||||
Specific test for a pattern which was deprecated in Django 1.8
|
||||
and which will become completely unsupported in Django 1.10.
|
||||
https://docs.djangoproject.com/en/1.8/howto/custom-management-commands/#custom-commands-options
|
||||
"""
|
||||
proc = subprocess.Popen(['django-cadmin', 'old_optparse_command', '--help'],
|
||||
stdout=subprocess.PIPE)
|
||||
output = proc.communicate()[0].decode('utf-8')
|
||||
self.assertIn('--configuration', output)
|
||||
self.assertIn('--arg1', output)
|
||||
|
|
|
|||
Loading…
Reference in a new issue