mirror of
https://github.com/jazzband/django-configurations.git
synced 2026-03-16 22:20:27 +00:00
Merge remote-tracking branch 'jdietrick/master' into upstream
Conflicts: .travis.yml
This commit is contained in:
commit
0a4f776df1
8 changed files with 49 additions and 12 deletions
|
|
@ -37,9 +37,10 @@ def install(check_options=False):
|
|||
if isinstance(parser, OptionParser):
|
||||
# in case the option_list is set the create_parser
|
||||
# will actually return a OptionParser for backward
|
||||
# compatibility. It uses BaseCommand.use_argparse
|
||||
# to decide that, which checks for the option_list list
|
||||
base.BaseCommand.option_list += configuration_options
|
||||
# compatibility. In that case we should tack our
|
||||
# options on to the end of the parser on the way out.
|
||||
for option in configuration_options:
|
||||
parser.add_option(option)
|
||||
else:
|
||||
# probably argparse, let's not import argparse though
|
||||
parser.add_argument(CONFIGURATION_ARGUMENT,
|
||||
|
|
|
|||
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
|
||||
|
|
@ -4,5 +4,6 @@ mock
|
|||
dj-database-url
|
||||
dj-email-url
|
||||
dj-search-url
|
||||
django-cache-url>=0.6.0
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -407,20 +407,19 @@ class ValueTests(TestCase):
|
|||
def test_cache_url_value(self):
|
||||
cache_setting = {
|
||||
'default': {
|
||||
'BACKEND': 'redis_cache.cache.RedisCache',
|
||||
'KEY_PREFIX': '',
|
||||
'LOCATION': 'host:port:1'
|
||||
'BACKEND': 'django_redis.cache.RedisCache',
|
||||
'LOCATION': 'host:12345:1'
|
||||
}
|
||||
}
|
||||
cache_url = 'redis://user@host:port/1'
|
||||
cache_url = 'redis://user@host:12345/1'
|
||||
value = CacheURLValue(cache_url)
|
||||
self.assertEqual(value.default, cache_setting)
|
||||
value = CacheURLValue()
|
||||
self.assertEqual(value.default, {})
|
||||
with env(CACHE_URL='redis://user@host:port/1'):
|
||||
with env(CACHE_URL='redis://user@host:12345/1'):
|
||||
self.assertEqual(value.setup('CACHE_URL'), cache_setting)
|
||||
with env(CACHE_URL='wrong://user@host:port/1'):
|
||||
self.assertRaises(KeyError, value.setup, 'TEST')
|
||||
with env(CACHE_URL='wrong://user@host:12345/1'):
|
||||
self.assertRaisesRegexp(Exception, 'Unknown backend: "wrong"', value.setup, 'TEST')
|
||||
|
||||
def test_search_url_value(self):
|
||||
value = SearchURLValue()
|
||||
|
|
|
|||
3
tox.ini
3
tox.ini
|
|
@ -7,7 +7,8 @@ envlist =
|
|||
flake8-py33,
|
||||
py{26,py}-dj{14,15,16},
|
||||
py27-dj{14,15,16,17,18,19},
|
||||
py{32,33,34,py}-dj{15,16,17,18,19}
|
||||
py{32,33,34,py}-dj{15,16,17,18}
|
||||
py{34,py}-dj19
|
||||
|
||||
[testenv]
|
||||
basepython =
|
||||
|
|
|
|||
Loading…
Reference in a new issue