mirror of
https://github.com/jazzband/django-constance.git
synced 2026-03-16 22:40:24 +00:00
Drop support py<3.5 django<2.2 (#359)
* Drop support py<3.5 django<2.2 * Remove admin_static
This commit is contained in:
parent
886f6d5235
commit
590fa02eb3
30 changed files with 58 additions and 142 deletions
11
.travis.yml
11
.travis.yml
|
|
@ -1,24 +1,17 @@
|
|||
sudo: false
|
||||
language: python
|
||||
cache: pip
|
||||
python:
|
||||
- 2.7
|
||||
- 3.5
|
||||
- 3.6
|
||||
- pypy
|
||||
- 3.7
|
||||
- 3.8
|
||||
- pypy3
|
||||
install: pip install tox-travis
|
||||
script: tox
|
||||
matrix:
|
||||
include:
|
||||
- python: 3.7
|
||||
dist: xenial
|
||||
sudo: required
|
||||
deploy:
|
||||
provider: pypi
|
||||
user: jazzband
|
||||
server: https://jazzband.co/projects/django-constance/upload
|
||||
distributions: sdist bdist_wheel
|
||||
password:
|
||||
secure: fvFbH0oZGYDad2rik7v0L+G4ItH0g/2v8hoBSajeyt/nEyoEShTh2xBwo5413NGkDaIYtYpP/MVqBy02uMc8oSNgh/rS1tIjiIKE77/YJNuZHyQXnZ+90JA+yGaJc5dOyd4G3szEp2Zzi18ov2KkCt37/arObu8bEbChWaEoJqI=
|
||||
on:
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ from django.utils.encoding import smart_bytes
|
|||
from django.utils.formats import localize
|
||||
from django.utils.module_loading import import_string
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
import six
|
||||
|
||||
from . import LazyConfig, settings
|
||||
from .checks import get_inconsistent_fieldnames
|
||||
|
|
@ -79,12 +78,6 @@ def parse_additional_fields(fields):
|
|||
|
||||
FIELDS.update(parse_additional_fields(settings.ADDITIONAL_FIELDS))
|
||||
|
||||
if not six.PY3:
|
||||
FIELDS.update({
|
||||
long: INTEGER_LIKE,
|
||||
unicode: STRING_LIKE,
|
||||
})
|
||||
|
||||
|
||||
def get_values():
|
||||
"""
|
||||
|
|
@ -105,7 +98,7 @@ class ConstanceForm(forms.Form):
|
|||
version = forms.CharField(widget=forms.HiddenInput)
|
||||
|
||||
def __init__(self, initial, *args, **kwargs):
|
||||
super(ConstanceForm, self).__init__(*args, initial=initial, **kwargs)
|
||||
super().__init__(*args, initial=initial, **kwargs)
|
||||
version_hash = hashlib.md5()
|
||||
|
||||
for name, options in settings.CONFIG.items():
|
||||
|
|
@ -163,7 +156,7 @@ class ConstanceForm(forms.Form):
|
|||
return value
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super(ConstanceForm, self).clean()
|
||||
cleaned_data = super().clean()
|
||||
|
||||
if not settings.CONFIG_FIELDSETS:
|
||||
return cleaned_data
|
||||
|
|
@ -294,11 +287,11 @@ class ConstanceAdmin(admin.ModelAdmin):
|
|||
def has_change_permission(self, request, obj=None):
|
||||
if settings.SUPERUSER_ONLY:
|
||||
return request.user.is_superuser
|
||||
return super(ConstanceAdmin, self).has_change_permission(request, obj)
|
||||
return super().has_change_permission(request, obj)
|
||||
|
||||
|
||||
class Config(object):
|
||||
class Meta(object):
|
||||
class Config:
|
||||
class Meta:
|
||||
app_label = 'constance'
|
||||
object_name = 'Config'
|
||||
model_name = module_name = 'config'
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class ConstanceConfig(AppConfig):
|
|||
verbose_name = 'Constance'
|
||||
|
||||
def ready(self):
|
||||
super(ConstanceConfig, self).ready()
|
||||
super().ready()
|
||||
signals.post_migrate.connect(self.create_perm,
|
||||
dispatch_uid='constance.create_perm')
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ Defines the base constance backend
|
|||
"""
|
||||
|
||||
|
||||
class Backend(object):
|
||||
class Backend:
|
||||
|
||||
def get(self, key):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
import picklefield.fields
|
||||
|
||||
|
|
|
|||
|
|
@ -20,5 +20,5 @@ class Constance(models.Model):
|
|||
verbose_name_plural = _('constances')
|
||||
db_table = 'constance_config'
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.key
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,15 @@
|
|||
from django.core.exceptions import ImproperlyConfigured
|
||||
import six
|
||||
|
||||
from . import Backend
|
||||
from .. import settings, utils, signals, config
|
||||
|
||||
try:
|
||||
from cPickle import loads, dumps
|
||||
except ImportError:
|
||||
from pickle import loads, dumps
|
||||
from pickle import loads, dumps
|
||||
|
||||
|
||||
class RedisBackend(Backend):
|
||||
|
||||
def __init__(self):
|
||||
super(RedisBackend, self).__init__()
|
||||
super().__init__()
|
||||
self._prefix = settings.REDIS_PREFIX
|
||||
connection_cls = settings.REDIS_CONNECTION_CLASS
|
||||
if connection_cls is not None:
|
||||
|
|
@ -24,7 +20,7 @@ class RedisBackend(Backend):
|
|||
except ImportError:
|
||||
raise ImproperlyConfigured(
|
||||
"The Redis backend requires redis-py to be installed.")
|
||||
if isinstance(settings.REDIS_CONNECTION, six.string_types):
|
||||
if isinstance(settings.REDIS_CONNECTION, str):
|
||||
self._rd = redis.from_url(settings.REDIS_CONNECTION)
|
||||
else:
|
||||
self._rd = redis.Redis(**settings.REDIS_CONNECTION)
|
||||
|
|
@ -42,7 +38,7 @@ class RedisBackend(Backend):
|
|||
if not keys:
|
||||
return
|
||||
prefixed_keys = [self.add_prefix(key) for key in keys]
|
||||
for key, value in six.moves.zip(keys, self._rd.mget(prefixed_keys)):
|
||||
for key, value in zip(keys, self._rd.mget(prefixed_keys)):
|
||||
if value:
|
||||
yield key, loads(value)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
from . import settings, utils
|
||||
|
||||
|
||||
class Config(object):
|
||||
class Config:
|
||||
"""
|
||||
The global config wrapper that handles the backend.
|
||||
"""
|
||||
def __init__(self):
|
||||
super(Config, self).__setattr__('_backend',
|
||||
super().__setattr__('_backend',
|
||||
utils.import_module_attr(settings.BACKEND)())
|
||||
|
||||
def __getattr__(self, key):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.management import BaseCommand, CommandError
|
||||
from django.utils.translation import ugettext as _
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "admin/base_site.html" %}
|
||||
{% load admin_static admin_list i18n %}
|
||||
{% load admin_list static i18n %}
|
||||
|
||||
{% block extrastyle %}
|
||||
{{ block.super }}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% load admin_static admin_list static i18n %}
|
||||
{% load admin_list static i18n %}
|
||||
<div id="results">
|
||||
<table>
|
||||
<thead>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class override_config(override_settings):
|
|||
Based on django.test.utils.override_settings.
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
super(override_config, self).__init__(**kwargs)
|
||||
super().__init__(**kwargs)
|
||||
self.original_values = {}
|
||||
|
||||
def __call__(self, test_func):
|
||||
|
|
|
|||
18
docs/conf.py
18
docs/conf.py
|
|
@ -1,5 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# django-constance documentation build configuration file, created by
|
||||
# sphinx-quickstart on Tue Nov 25 19:38:51 2014.
|
||||
#
|
||||
|
|
@ -45,8 +43,8 @@ source_suffix = '.rst'
|
|||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'django-constance'
|
||||
copyright = u'2017, Jazzband'
|
||||
project = 'django-constance'
|
||||
copyright = '2017, Jazzband'
|
||||
|
||||
# The short X.Y version.
|
||||
try:
|
||||
|
|
@ -199,8 +197,8 @@ latex_elements = {
|
|||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
('index', 'django-constance.tex', u'django-constance Documentation',
|
||||
u'Jazzband', 'manual'),
|
||||
('index', 'django-constance.tex', 'django-constance Documentation',
|
||||
'Jazzband', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
|
@ -229,8 +227,8 @@ latex_documents = [
|
|||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'django-constance', u'django-constance Documentation',
|
||||
[u'Jazzband'], 1)
|
||||
('index', 'django-constance', 'django-constance Documentation',
|
||||
['Jazzband'], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
|
|
@ -243,8 +241,8 @@ man_pages = [
|
|||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'django-constance', u'django-constance Documentation',
|
||||
u'Jazzband', 'django-constance', 'One line description of project.',
|
||||
('index', 'django-constance', 'django-constance Documentation',
|
||||
'Jazzband', 'django-constance', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -109,9 +109,7 @@ The supported types are:
|
|||
* ``int``
|
||||
* ``float``
|
||||
* ``Decimal``
|
||||
* ``long`` (on python 2)
|
||||
* ``str``
|
||||
* ``unicode`` (on python 2)
|
||||
* ``datetime``
|
||||
* ``date``
|
||||
* ``time``
|
||||
|
|
@ -359,7 +357,7 @@ settings the way you like.
|
|||
from constance.admin import ConstanceAdmin, ConstanceForm, Config
|
||||
class CustomConfigForm(ConstanceForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(CustomConfigForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
#... do stuff to make your settings form nice ...
|
||||
|
||||
class ConfigAdmin(ConstanceAdmin):
|
||||
|
|
@ -384,7 +382,7 @@ request. For example:
|
|||
if request.user.is_superuser:
|
||||
return SuperuserForm:
|
||||
else:
|
||||
return super(MyConstanceAdmin, self).get_changelist_form(request)
|
||||
return super().get_changelist_form(request)
|
||||
|
||||
Note that the default method returns ``self.change_list_form``.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
[bdist_wheel]
|
||||
universal = 1
|
||||
14
setup.py
14
setup.py
|
|
@ -22,31 +22,30 @@ def find_version(*file_paths):
|
|||
setup(
|
||||
name='django-constance',
|
||||
version=find_version("constance", "__init__.py"),
|
||||
url="http://github.com/jazzband/django-constance",
|
||||
url="https://github.com/jazzband/django-constance",
|
||||
description='Django live settings with pluggable backends, including Redis.',
|
||||
long_description=read('README.rst'),
|
||||
author='Jannis Leidel',
|
||||
author_email='jannis@leidel.info',
|
||||
license='BSD',
|
||||
keywords='django libraries settings redis'.split(),
|
||||
platforms='any',
|
||||
platforms=['any'],
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Environment :: Web Environment',
|
||||
'Framework :: Django',
|
||||
'Framework :: Django :: 1.11',
|
||||
'Framework :: Django :: 2.1',
|
||||
'Framework :: Django :: 2.2',
|
||||
'Framework :: Django :: 3.0',
|
||||
'Intended Audience :: Developers',
|
||||
'License :: OSI Approved :: BSD License',
|
||||
'Natural Language :: English',
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 2',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.5',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
'Programming Language :: Python :: 3 :: Only',
|
||||
'Programming Language :: Python :: Implementation :: CPython',
|
||||
'Programming Language :: Python :: Implementation :: PyPy',
|
||||
'Topic :: Utilities',
|
||||
|
|
@ -54,7 +53,6 @@ setup(
|
|||
packages=find_packages(exclude=['tests', 'tests.*']),
|
||||
include_package_data=True,
|
||||
zip_safe=False,
|
||||
install_requires=['six'],
|
||||
extras_require={
|
||||
'database': ['django-picklefield'],
|
||||
'redis': ['redis'],
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
from django.utils import six
|
||||
|
||||
from datetime import datetime, date, time, timedelta
|
||||
from decimal import Decimal
|
||||
|
||||
|
|
@ -46,11 +43,6 @@ ROOT_URLCONF = 'tests.urls'
|
|||
|
||||
CONSTANCE_REDIS_CONNECTION_CLASS = 'tests.redis_mockup.Connection'
|
||||
|
||||
long_value = 123456
|
||||
|
||||
if not six.PY3:
|
||||
long_value = long(long_value)
|
||||
|
||||
CONSTANCE_ADDITIONAL_FIELDS = {
|
||||
'yes_no_null_select': [
|
||||
'django.forms.fields.ChoiceField',
|
||||
|
|
@ -67,10 +59,8 @@ USE_TZ = True
|
|||
|
||||
CONSTANCE_CONFIG = {
|
||||
'INT_VALUE': (1, 'some int'),
|
||||
'LONG_VALUE': (long_value, 'some looong int'),
|
||||
'BOOL_VALUE': (True, 'true or false'),
|
||||
'STRING_VALUE': ('Hello world', 'greetings'),
|
||||
'UNICODE_VALUE': (u'Rivière-Bonjour რუსთაველი', 'greetings'),
|
||||
'DECIMAL_VALUE': (Decimal('0.1'), 'the first release version'),
|
||||
'DATETIME_VALUE': (datetime(2010, 8, 23, 11, 29, 24),
|
||||
'time of the first commit'),
|
||||
|
|
|
|||
|
|
@ -1,28 +1,19 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
from datetime import datetime, date, time, timedelta
|
||||
from decimal import Decimal
|
||||
|
||||
from django.utils import six
|
||||
|
||||
from constance.base import Config
|
||||
|
||||
if six.PY3:
|
||||
def long(value):
|
||||
return value
|
||||
|
||||
|
||||
class StorageTestsMixin(object):
|
||||
class StorageTestsMixin:
|
||||
|
||||
def setUp(self):
|
||||
self.config = Config()
|
||||
super(StorageTestsMixin, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
def test_store(self):
|
||||
self.assertEqual(self.config.INT_VALUE, 1)
|
||||
self.assertEqual(self.config.LONG_VALUE, long(123456))
|
||||
self.assertEqual(self.config.BOOL_VALUE, True)
|
||||
self.assertEqual(self.config.STRING_VALUE, 'Hello world')
|
||||
self.assertEqual(self.config.UNICODE_VALUE, u'Rivière-Bonjour რუსთაველი')
|
||||
self.assertEqual(self.config.DECIMAL_VALUE, Decimal('0.1'))
|
||||
self.assertEqual(self.config.DATETIME_VALUE, datetime(2010, 8, 23, 11, 29, 24))
|
||||
self.assertEqual(self.config.FLOAT_VALUE, 3.1415926536)
|
||||
|
|
@ -34,10 +25,8 @@ class StorageTestsMixin(object):
|
|||
|
||||
# set values
|
||||
self.config.INT_VALUE = 100
|
||||
self.config.LONG_VALUE = long(654321)
|
||||
self.config.BOOL_VALUE = False
|
||||
self.config.STRING_VALUE = 'Beware the weeping angel'
|
||||
self.config.UNICODE_VALUE = u'Québec'
|
||||
self.config.DECIMAL_VALUE = Decimal('1.2')
|
||||
self.config.DATETIME_VALUE = datetime(1977, 10, 2)
|
||||
self.config.FLOAT_VALUE = 2.718281845905
|
||||
|
|
@ -49,10 +38,8 @@ class StorageTestsMixin(object):
|
|||
|
||||
# read again
|
||||
self.assertEqual(self.config.INT_VALUE, 100)
|
||||
self.assertEqual(self.config.LONG_VALUE, long(654321))
|
||||
self.assertEqual(self.config.BOOL_VALUE, False)
|
||||
self.assertEqual(self.config.STRING_VALUE, 'Beware the weeping angel')
|
||||
self.assertEqual(self.config.UNICODE_VALUE, u'Québec')
|
||||
self.assertEqual(self.config.DECIMAL_VALUE, Decimal('1.2'))
|
||||
self.assertEqual(self.config.DATETIME_VALUE, datetime(1977, 10, 2))
|
||||
self.assertEqual(self.config.FLOAT_VALUE, 2.718281845905)
|
||||
|
|
@ -75,19 +62,15 @@ class StorageTestsMixin(object):
|
|||
|
||||
def test_missing_values(self):
|
||||
# set some values and leave out others
|
||||
self.config.LONG_VALUE = long(654321)
|
||||
self.config.BOOL_VALUE = False
|
||||
self.config.UNICODE_VALUE = u'Québec'
|
||||
self.config.DECIMAL_VALUE = Decimal('1.2')
|
||||
self.config.DATETIME_VALUE = datetime(1977, 10, 2)
|
||||
self.config.DATE_VALUE = date(2001, 12, 20)
|
||||
self.config.TIME_VALUE = time(1, 59, 0)
|
||||
|
||||
self.assertEqual(self.config.INT_VALUE, 1) # this should be the default value
|
||||
self.assertEqual(self.config.LONG_VALUE, long(654321))
|
||||
self.assertEqual(self.config.BOOL_VALUE, False)
|
||||
self.assertEqual(self.config.STRING_VALUE, 'Hello world') # this should be the default value
|
||||
self.assertEqual(self.config.UNICODE_VALUE, u'Québec')
|
||||
self.assertEqual(self.config.DECIMAL_VALUE, Decimal('1.2'))
|
||||
self.assertEqual(self.config.DATETIME_VALUE, datetime(1977, 10, 2))
|
||||
self.assertEqual(self.config.FLOAT_VALUE, 3.1415926536) # this should be the default value
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ from django.core.exceptions import PermissionDenied
|
|||
from django.http import HttpResponseRedirect
|
||||
from django.template.defaultfilters import linebreaksbr
|
||||
from django.test import TestCase, RequestFactory
|
||||
from django.utils import six
|
||||
|
||||
from constance import settings
|
||||
from constance.admin import Config
|
||||
|
|
@ -18,7 +17,7 @@ class TestAdmin(TestCase):
|
|||
model = Config
|
||||
|
||||
def setUp(self):
|
||||
super(TestAdmin, self).setUp()
|
||||
super().setUp()
|
||||
self.rf = RequestFactory()
|
||||
self.superuser = User.objects.create_superuser('admin', 'nimda', 'a@a.cz')
|
||||
self.normaluser = User.objects.create_user('normal', 'nimda', 'b@b.cz')
|
||||
|
|
@ -55,7 +54,7 @@ class TestAdmin(TestCase):
|
|||
|
||||
def test_str(self):
|
||||
ct = ContentType.objects.get(app_label='constance', model='config')
|
||||
self.assertEqual(six.text_type(ct), 'config')
|
||||
self.assertEqual(str(ct), 'config')
|
||||
|
||||
def test_linebreaks(self):
|
||||
self.client.login(username='admin', password='nimda')
|
||||
|
|
@ -66,8 +65,8 @@ class TestAdmin(TestCase):
|
|||
self.assertContains(response, linebreaksbr('eggs\neggs'))
|
||||
|
||||
@mock.patch('constance.settings.CONFIG_FIELDSETS', {
|
||||
'Numbers': ('LONG_VALUE', 'INT_VALUE',),
|
||||
'Text': ('STRING_VALUE', 'UNICODE_VALUE'),
|
||||
'Numbers': ('INT_VALUE',),
|
||||
'Text': ('STRING_VALUE',),
|
||||
})
|
||||
def test_fieldset_headers(self):
|
||||
self.client.login(username='admin', password='nimda')
|
||||
|
|
@ -123,8 +122,8 @@ class TestAdmin(TestCase):
|
|||
self.assertIsInstance(response, HttpResponseRedirect)
|
||||
|
||||
@mock.patch('constance.settings.CONFIG_FIELDSETS', {
|
||||
'Numbers': ('LONG_VALUE', 'INT_VALUE',),
|
||||
'Text': ('STRING_VALUE', 'UNICODE_VALUE'),
|
||||
'Numbers': ('INT_VALUE',),
|
||||
'Text': ('STRING_VALUE',),
|
||||
})
|
||||
def test_inconsistent_fieldset_submit(self):
|
||||
"""
|
||||
|
|
@ -139,7 +138,7 @@ class TestAdmin(TestCase):
|
|||
self.assertContains(response, 'is missing field(s)')
|
||||
|
||||
@mock.patch('constance.settings.CONFIG_FIELDSETS', {
|
||||
'Numbers': ('LONG_VALUE', 'INT_VALUE',),
|
||||
'Fieldsets': ('STRING_VALUE', 'INT_VALUE',),
|
||||
})
|
||||
def test_fieldset_ordering_1(self):
|
||||
"""Ordering of inner list should be preserved"""
|
||||
|
|
@ -148,14 +147,14 @@ class TestAdmin(TestCase):
|
|||
request.user = self.superuser
|
||||
response = self.options.changelist_view(request, {})
|
||||
response.render()
|
||||
content_str = response.content.decode('utf-8')
|
||||
content_str = response.content.decode()
|
||||
self.assertGreater(
|
||||
content_str.find('INT_VALUE'),
|
||||
content_str.find('LONG_VALUE')
|
||||
content_str.find('STRING_VALUE')
|
||||
)
|
||||
|
||||
@mock.patch('constance.settings.CONFIG_FIELDSETS', {
|
||||
'Numbers': ('INT_VALUE', 'LONG_VALUE', ),
|
||||
'Fieldsets': ('INT_VALUE', 'STRING_VALUE',),
|
||||
})
|
||||
def test_fieldset_ordering_2(self):
|
||||
"""Ordering of inner list should be preserved"""
|
||||
|
|
@ -164,9 +163,9 @@ class TestAdmin(TestCase):
|
|||
request.user = self.superuser
|
||||
response = self.options.changelist_view(request, {})
|
||||
response.render()
|
||||
content_str = response.content.decode('utf-8')
|
||||
content_str = response.content.decode()
|
||||
self.assertGreater(
|
||||
content_str.find('LONG_VALUE'),
|
||||
content_str.find('STRING_VALUE'),
|
||||
content_str.find('INT_VALUE')
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import datetime
|
||||
from decimal import Decimal
|
||||
import mock
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datetime import datetime
|
||||
from textwrap import dedent
|
||||
|
||||
|
|
@ -8,7 +6,7 @@ from django.core.management import call_command, CommandError
|
|||
from django.test import TransactionTestCase
|
||||
from django.utils import timezone
|
||||
from django.utils.encoding import smart_str
|
||||
from six import StringIO
|
||||
from io import StringIO
|
||||
|
||||
from constance import config
|
||||
|
||||
|
|
@ -27,16 +25,14 @@ class CliTestCase(TransactionTestCase):
|
|||
call_command('constance', 'list', stdout=self.out)
|
||||
|
||||
self.assertEqual(set(self.out.getvalue().splitlines()), set(dedent(smart_str(
|
||||
u""" BOOL_VALUE True
|
||||
""" BOOL_VALUE True
|
||||
EMAIL_VALUE test@example.com
|
||||
INT_VALUE 1
|
||||
LINEBREAK_VALUE Spam spam
|
||||
DATE_VALUE 2010-12-24
|
||||
TIME_VALUE 23:59:59
|
||||
TIMEDELTA_VALUE 1 day, 2:03:00
|
||||
LONG_VALUE 123456
|
||||
STRING_VALUE Hello world
|
||||
UNICODE_VALUE Rivière-Bonjour რუსთაველი
|
||||
CHOICE_VALUE yes
|
||||
DECIMAL_VALUE 0.1
|
||||
DATETIME_VALUE 2010-08-23 11:29:24
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class TestDatabase(StorageTestsMixin, TestCase):
|
|||
def setUp(self):
|
||||
self.old_backend = settings.BACKEND
|
||||
settings.BACKEND = 'constance.backends.database.DatabaseBackend'
|
||||
super(TestDatabase, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
def test_database_queries(self):
|
||||
# Read and set to default value
|
||||
|
|
|
|||
|
|
@ -10,10 +10,8 @@ class TestForm(TestCase):
|
|||
f = ConstanceForm({})
|
||||
|
||||
self.assertIsInstance(f.fields['INT_VALUE'], fields.IntegerField)
|
||||
self.assertIsInstance(f.fields['LONG_VALUE'], fields.IntegerField)
|
||||
self.assertIsInstance(f.fields['BOOL_VALUE'], fields.BooleanField)
|
||||
self.assertIsInstance(f.fields['STRING_VALUE'], fields.CharField)
|
||||
self.assertIsInstance(f.fields['UNICODE_VALUE'], fields.CharField)
|
||||
self.assertIsInstance(f.fields['DECIMAL_VALUE'], fields.DecimalField)
|
||||
self.assertIsInstance(f.fields['DATETIME_VALUE'], fields.SplitDateTimeField)
|
||||
self.assertIsInstance(f.fields['TIMEDELTA_VALUE'], fields.DurationField)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class TestRedis(StorageTestsMixin, TestCase):
|
|||
def setUp(self):
|
||||
self.old_backend = settings.BACKEND
|
||||
settings.BACKEND = 'constance.backends.redisd.RedisBackend'
|
||||
super(TestRedis, self).setUp()
|
||||
super().setUp()
|
||||
self.config._backend._rd.clear()
|
||||
|
||||
def tearDown(self):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import datetime
|
||||
from decimal import Decimal
|
||||
|
||||
|
|
@ -31,7 +29,5 @@ class UtilsTestCase(TestCase):
|
|||
'LINEBREAK_VALUE': 'Spam spam',
|
||||
'DECIMAL_VALUE': Decimal('0.1'),
|
||||
'STRING_VALUE': 'Hello world',
|
||||
'UNICODE_VALUE': u'Rivière-Bonjour რუსთაველი',
|
||||
'DATETIME_VALUE': datetime.datetime(2010, 8, 23, 11, 29, 24),
|
||||
'LONG_VALUE': 123456
|
||||
})
|
||||
|
|
|
|||
13
tox.ini
13
tox.ini
|
|
@ -1,9 +1,8 @@
|
|||
[tox]
|
||||
envlist =
|
||||
py{27,35,36,37,py,py3}-django-111
|
||||
py{35,36,37,py3}-django-21
|
||||
py{37}-django-22
|
||||
py{37}-django-master
|
||||
py{35,36,37,pypy3}-django{22}
|
||||
py{36,37,38}-django{30}
|
||||
py{36,37,38}-django-master
|
||||
|
||||
[testenv]
|
||||
deps =
|
||||
|
|
@ -11,10 +10,8 @@ deps =
|
|||
coverage
|
||||
mock
|
||||
django-picklefield
|
||||
django-111: Django>=1.11,<2.0
|
||||
django-20: Django>=2.0,<2.1
|
||||
django-21: Django>=2.1,<2.2
|
||||
django-22: Django>=2.2b1,<2.3
|
||||
django-22: Django>=2.2,<3.0
|
||||
django-30: Django>=3.0,<3.1
|
||||
django-master: https://github.com/django/django/archive/master.tar.gz
|
||||
usedevelop = True
|
||||
ignore_outcome =
|
||||
|
|
|
|||
Loading…
Reference in a new issue