Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 11 additions & 32 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,23 @@
language: python
python:
- 2.7
- 3.3
- 3.4
- 3.5
- 3.6
env:
- DJANGO='django>=1.3,<1.4'
- DJANGO='django>=1.4,<1.5'
- DJANGO='django>=1.5,<1.6'
- DJANGO='django>=1.6,<1.7'
- DJANGO='django>=1.7,<1.8'
- DJANGO='django>=1.8,<1.9'
- DJANGO='django>=1.9,<1.10'
- DJANGO='django>=1.10,<1.11'
- DJANGO='django>=1.11,<2.0'
- DJANGO='django>=2.0,<2.1'
- DJANGO='django>=2.1,<2.2'
sudo: false
install:
- pip install $DJANGO
script:
- python runtests.py
matrix:
exclude:
- python: 3.3
env: DJANGO='django>=1.3,<1.4'
- python: 3.3
env: DJANGO='django>=1.4,<1.5'
- python: 3.3
env: DJANGO='django>=1.9,<1.10'
- python: 3.3
env: DJANGO='django>=1.10,<1.11'
- python: 3.4
env: DJANGO='django>=1.3,<1.4'
- python: 3.4
env: DJANGO='django>=1.4,<1.5'
- python: 3.5
env: DJANGO='django>=1.3,<1.4'
- python: 3.5
env: DJANGO='django>=1.4,<1.5'
- python: 3.5
env: DJANGO='django>=1.5,<1.6'
- python: 3.5
env: DJANGO='django>=1.6,<1.7'
- python: 3.5
env: DJANGO='django>=1.7,<1.8'
exclude:
- python: 2.7
env: DJANGO='django>=2.0,<2.1'
- python: 2.7
env: DJANGO='django>=2.1,<2.2'
- python: 3.4
env: DJANGO='django>=2.1,<2.2'
13 changes: 0 additions & 13 deletions classytags/compat.py

This file was deleted.

8 changes: 4 additions & 4 deletions classytags/core.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from operator import attrgetter

from django.template import Node
from django.utils import six

from classytags.blocks import BlockDefinition
from classytags.compat import compat_basestring
from classytags.parser import Parser
from classytags.utils import StructuredOptions
from classytags.utils import get_default_name
Expand All @@ -25,8 +25,8 @@ def __init__(self, *options, **kwargs):
self.options[current_breakpoint] = []
self.all_argument_names = []
for value in options:
if isinstance(value, compat_basestring):
if isinstance(last, compat_basestring):
if isinstance(value, six.string_types):
if isinstance(last, six.string_types):
self.combined_breakpoints[last] = value
self.breakpoints.append(value)
current_breakpoint = value
Expand All @@ -39,7 +39,7 @@ def __init__(self, *options, **kwargs):
for block in kwargs.get('blocks', []):
if isinstance(block, BlockDefinition):
block_definition = block
elif isinstance(block, compat_basestring):
elif isinstance(block, six.string_types):
block_definition = BlockDefinition(block, block)
else:
block_definition = BlockDefinition(block[1], block[0])
Expand Down
Empty file removed classytags/models.py
Empty file.
9 changes: 2 additions & 7 deletions classytags/test/context_managers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
# -*- coding: utf-8 -*-
from django import template
from django.conf import settings
from django.template.engine import Engine


try:
Engine = None
builtins = template.base.builtins
except AttributeError:
from django.template.engine import Engine
builtins = Engine.get_default().template_builtins
builtins = Engine.get_default().template_builtins


class NULL:
Expand Down
Empty file removed classytags/test/project/models.py
Empty file.
42 changes: 10 additions & 32 deletions classytags/tests.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
from __future__ import with_statement

import os
import sys
import warnings
from distutils.version import LooseVersion
import operator
from unittest import TestCase

import django
from django import template
from django.core.exceptions import ImproperlyConfigured
from django.template import Context, RequestContext
from django.test import RequestFactory
from django.utils import six

from classytags import arguments
from classytags import core
Expand All @@ -22,17 +19,9 @@
from classytags import values
from classytags.blocks import BlockDefinition
from classytags.blocks import VariableBlockName
from classytags.compat import compat_next
from classytags.test.context_managers import SettingsOverride
from classytags.test.context_managers import TemplateTags

DJANGO_1_4_OR_HIGHER = (
LooseVersion(django.get_version()) >= LooseVersion('1.4')
)
DJANGO_1_5_OR_HIGHER = (
LooseVersion(django.get_version()) >= LooseVersion('1.5')
)

CLASSY_TAGS_DIR = os.path.abspath(os.path.dirname(__file__))


Expand Down Expand Up @@ -539,7 +528,7 @@ def render_tag(self, context, values, varname):
if self not in context.render_context:
context.render_context[self] = itertools_cycle(values)
cycle_iter = context.render_context[self]
value = compat_next(cycle_iter)
value = six.next(cycle_iter)
if varname:
context[varname] = value
return value
Expand Down Expand Up @@ -835,21 +824,16 @@ class Fail4(helpers.AsTag):
arguments.Argument('varname', resolve=False),
)

if DJANGO_1_4_OR_HIGHER:
exc_class = NotImplementedError
else: # pragma: no cover
exc_class = template.TemplateSyntaxError

with TemplateTags(Fail, Fail2, Fail3, Fail4):
context = template.Context({})
tpl = template.Template("{% fail %}")
self.assertRaises(exc_class, tpl.render, context)
self.assertRaises(NotImplementedError, tpl.render, context)
self.assertRaises(ImproperlyConfigured,
template.Template, "{% fail2 %}")
self.assertRaises(ImproperlyConfigured,
template.Template, "{% fail3 %}")
tpl = template.Template("{% fail4 as something %}")
self.assertRaises(exc_class, tpl.render, context)
self.assertRaises(NotImplementedError, tpl.render, context)

def test_too_many_arguments(self):
class NoArg(core.Tag):
Expand Down Expand Up @@ -1470,13 +1454,10 @@ def test_flatten_context(self):
expected = {
'foo': 'test',
'bar': 'baz',
'None': None,
'True': True,
'False': False,
}
if DJANGO_1_5_OR_HIGHER:
expected.update({
'None': None,
'True': True,
'False': False,
})
self.assertEqual(flat, expected)
context.flatten = None
flat = utils.flatten_context(context)
Expand All @@ -1491,13 +1472,10 @@ def test_flatten_requestcontext(self):
'foo': 'test',
'request': 'bar',
'bar': 'baz',
'None': None,
'True': True,
'False': False,
}
if DJANGO_1_5_OR_HIGHER:
expected.update({
'None': None,
'True': True,
'False': False,
})

checked_keys = expected.keys()

Expand Down
12 changes: 3 additions & 9 deletions classytags/utils.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import re
from copy import copy
from distutils.version import LooseVersion

from classytags.compat import compat_basestring
from django import get_version
from django.template import Context, RequestContext
from django.template.context import BaseContext

DJANGO_1_9_OR_HIGHER = (
LooseVersion(get_version()) >= LooseVersion('1.9')
)
from django.utils import six


class NULL:
Expand All @@ -25,7 +19,7 @@ class TemplateConstant(object):
"""
def __init__(self, value):
self.literal = value
if isinstance(value, compat_basestring):
if isinstance(value, six.string_types):
self.value = value.strip('"\'')
else:
self.value = value
Expand Down Expand Up @@ -102,7 +96,7 @@ def do_flatten(context):
flat.update(d)
return flat

if callable(getattr(context, 'flatten', None)) and DJANGO_1_9_OR_HIGHER:
if callable(getattr(context, 'flatten', None)):
return context.flatten()
elif isinstance(context, BaseContext):
return do_flatten(context)
Expand Down
4 changes: 2 additions & 2 deletions classytags/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from django import template
from django.conf import settings
from django.utils import six

from classytags.compat import compat_basestring
from classytags.exceptions import TemplateSyntaxWarning


Expand Down Expand Up @@ -48,7 +48,7 @@ class StrictStringValue(StringValue):
value_on_error = ""

def clean(self, value):
if not isinstance(value, compat_basestring):
if not isinstance(value, six.string_types):
return self.error(value, "clean")
return value

Expand Down
14 changes: 10 additions & 4 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Changelog
#########

*****
0.9.0
*****

* Added testing for Django 1.11, 2.0, and 2.1; and dropped testing for older
versions.

*****
0.8.0
Expand Down Expand Up @@ -94,7 +100,7 @@ Changelog
* Fixed issue in :class:`classytags.arguments.MultiKeywordArgument` and
:class:`classytags.arguments.KeywordArgument` and their behavior when given
a default value.

*****
0.3.1
*****
Expand All @@ -111,7 +117,7 @@ Changelog

* Added :class:`classytags.arguments.KeywordArgument`
* Added :class:`classytags.arguments.MultiKeywordArgument`
* Added :class:`classytags.arguments.ChoiceArgument`
* Added :class:`classytags.arguments.ChoiceArgument`
* Added ability to override the parser class in the initialization of the
:class:`classytags.core.Options` class, to make the usage of custom parsers
easier.
Expand All @@ -126,7 +132,7 @@ Changelog
variable to store the value in, but no argument is given.
* Fixed :class:`classytags.helpers.InclusionTag` not validating the ``template``
attribute on initialization.

*****
0.2.1
*****
Expand All @@ -141,7 +147,7 @@ Changelog
* Added :class:`classytags.arguments.IntegerArgument`
* Added more graceful failing in non-debug mode by using warnings instead of
exceptions.

*****
0.1.3
*****
Expand Down
8 changes: 3 additions & 5 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ Installation
To install django-classy-tags, please use
``sudo pip install django-classy-tags``.

If you don't want to use ``pip``, download the latest version from
If you don't want to use ``pip``, download the latest version from
`pypi <http://pypi.python.org/pypi/django-classy-tags>`_, unpack the tarball and
run ``sudo python setup.py install``.

django-classy-tags has no dependencies other than Django. Django 1.3, 1.4, 1.5,
1.6, 1.7, 1.8, 1.9 and 1.10 are supportd.

django-classy-tags supports Python 2.7, 3.3, 3.4 and 3.5.
django-classy-tags has no dependencies other than Django. Django 1.11 and
later are supported.
Loading