[Python-modules-commits] [django-classy-tags] 03/12: Import django-classy-tags_0.8.0.orig.tar.gz
Michael Fladischer
fladi at moszumanska.debian.org
Thu Sep 1 07:46:22 UTC 2016
This is an automated email from the git hooks/post-receive script.
fladi pushed a commit to branch master
in repository django-classy-tags.
commit 000ea39c348370b7fb7183eb700772a54c16006e
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date: Thu Sep 1 09:28:08 2016 +0200
Import django-classy-tags_0.8.0.orig.tar.gz
---
.travis.yml | 10 +--
README.rst | 2 +-
classytags/__init__.py | 2 +-
classytags/core.py | 29 +++++----
classytags/tests.py | 165 ++++++++++++++++++++++++++++++++++++++-----------
docs/changes.rst | 7 +++
docs/installation.rst | 5 +-
runtests.py | 12 ++++
setup.py | 1 -
9 files changed, 173 insertions(+), 60 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 1597929..b51f0d1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,5 @@
language: python
python:
- - 2.6
- 2.7
- 3.3
- 3.4
@@ -13,6 +12,7 @@ env:
- DJANGO='django>=1.7,<1.8'
- DJANGO='django>=1.8,<1.9'
- DJANGO='django>=1.9,<1.10'
+ - DJANGO='django>=1.10,<1.11'
sudo: false
install:
- pip install $DJANGO
@@ -20,18 +20,14 @@ script:
- python runtests.py
matrix:
exclude:
- - python: 2.6
- env: DJANGO='django>=1.7,<1.8'
- - python: 2.6
- env: DJANGO='django>=1.8,<1.9'
- - python: 2.6
- env: DJANGO='django>=1.9,<1.10'
- 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
diff --git a/README.rst b/README.rst
index e5c37ed..8cfba98 100644
--- a/README.rst
+++ b/README.rst
@@ -3,7 +3,7 @@ django-classy-tags
==================
Please refer to the documentation in the docs/ directory for help. For a HTML
-rendered version of it please see `here <http://django-classy-tags.rtfd.org>`_.
+rendered version of it please see `here <https://django-classy-tags.readthedocs.io>`_.
.. image:: https://travis-ci.org/ojii/django-classy-tags.svg?branch=master
:target: https://travis-ci.org/ojii/django-classy-tags
diff --git a/classytags/__init__.py b/classytags/__init__.py
index fb9b668..32a90a3 100644
--- a/classytags/__init__.py
+++ b/classytags/__init__.py
@@ -1 +1 @@
-__version__ = '0.7.2'
+__version__ = '0.8.0'
diff --git a/classytags/core.py b/classytags/core.py
index 52cf461..916930d 100644
--- a/classytags/core.py
+++ b/classytags/core.py
@@ -14,6 +14,8 @@ class Options(object):
Option class holding the arguments of a tag.
"""
def __init__(self, *options, **kwargs):
+ self._options = options
+ self._kwargs = kwargs
self.options = {}
self.raw_options = options
self.breakpoints = []
@@ -63,19 +65,24 @@ class Options(object):
def __add__(self, other):
if not isinstance(other, Options):
- raise TypeError("Cannot add non-Options to Options")
- if all((self.blocks, other.blocks)):
- raise TypeError("Cannot add Options that both define blocks")
- if self.parser_class != other.parser_class:
- raise TypeError(
- "Cannot add Options that have different parser classes"
+ raise TypeError("Cannot add Options to non-Options object")
+ if self.blocks and other.blocks:
+ raise ValueError(
+ "Cannot add two Options objects if both objects define blocks"
)
- kwargs = {
- 'parser_class': self.parser_class,
- 'blocks': self.blocks or other.blocks
+ if self.parser_class is not other.parser_class:
+ raise ValueError(
+ "Cannot add two Options objects with different parser classes"
+ )
+ full_options = self._options + other._options
+ full_kwargs = {
+ 'parser_class': self.parser_class
}
- args = list(self.raw_options) + list(other.raw_options)
- return Options(*args, **kwargs)
+ if self._kwargs.get('blocks', False):
+ full_kwargs['blocks'] = self._kwargs['blocks']
+ elif other._kwargs.get('blocks', False):
+ full_kwargs['blocks'] = other._kwargs['blocks']
+ return Options(*full_options, **full_kwargs)
def get_parser_class(self):
return self.parser_class
diff --git a/classytags/tests.py b/classytags/tests.py
index 294074f..a496610 100644
--- a/classytags/tests.py
+++ b/classytags/tests.py
@@ -1,10 +1,10 @@
from __future__ import with_statement
-import operator
import os
import sys
import warnings
from distutils.version import LooseVersion
+import operator
from unittest import TestCase
import django
@@ -631,6 +631,36 @@ class ClassytagsTests(TestCase):
]
self._tag_tester(Hello, tpls)
+ def test_filters_in_arguments(self):
+ class Filtered(core.Tag):
+ options = core.Options(
+ arguments.Argument('value'),
+ )
+
+ def render_tag(self, context, value):
+ return value
+ tpls = [
+ ('{% filtered "hello" %}', 'hello', {}),
+ ('{% filtered var %}', 'world', {'var': 'world'}),
+ ('{% filtered var|default:"foo" %}', 'foo', {}),
+ ]
+ self._tag_tester(Filtered, tpls)
+
+ def test_filtered_multi_keyword(self):
+ class Filtered(core.Tag):
+ options = core.Options(
+ arguments.MultiKeywordArgument('kwargs'),
+ )
+
+ def render_tag(self, context, kwargs):
+ return '|'.join('%s:%s' % (k, v) for k, v in kwargs.items())
+ tpls = [
+ ('{% filtered hello="world" %}', 'hello:world', {}),
+ ('{% filtered hello=var %}', 'hello:world', {'var': 'world'}),
+ ('{% filtered hello=var|default:"foo" %}', 'hello:foo', {}),
+ ]
+ self._tag_tester(Filtered, tpls)
+
def test_blocks(self):
class Blocky(core.Tag):
options = core.Options(
@@ -1319,55 +1349,116 @@ class MultiBreakpointTests(TestCase):
options.parse, dummy_parser, dummy_tokens
)
- def test_repr(self):
- options = core.Options(
- arguments.Argument('first'),
- 'breakpoint',
- arguments.Flag('flag', true_values=['yes']),
- blocks=['block']
+ def test_add_options(self):
+ options1 = core.Options(
+ arguments.Argument('first')
)
- self.assertEqual(
- repr(options),
- '<Options:<Argument: first>,breakpoint,<Flag: flag>;block>'
+ options2 = core.Options(
+ arguments.Argument('second')
)
+ combined = options1 + options2
+ self.assertEqual(len(combined.options), 1, combined.options)
+ self.assertIn(None, combined.options)
+ self.assertEqual(len(combined.options[None]), 2, combined.options[None])
+ self.assertEqual(combined.all_argument_names, ['first', 'second'])
+ self.assertEqual(len(combined.blocks), 0, combined.blocks)
- def test_add_options(self):
- left = core.Options(
- arguments.Argument('left')
+ def test_add_options_blocks_first(self):
+ options1 = core.Options(
+ arguments.Argument('first'),
+ blocks=['a']
)
- right = core.Options(
- arguments.Argument('right')
+ options2 = core.Options(
+ arguments.Argument('second'),
)
- combined = left + right
- dummy_tokens = DummyTokens('leftval', 'rightval')
- kwargs, blocks = combined.parse(dummy_parser, dummy_tokens)
- self.assertEqual(blocks, {})
- self.assertEqual(len(kwargs), 2)
- dummy_context = {}
- self.assertEqual(kwargs['left'].resolve(dummy_context), 'leftval')
- self.assertEqual(kwargs['right'].resolve(dummy_context), 'rightval')
+ combined = options1 + options2
+ self.assertEqual(len(combined.blocks), 1, combined.blocks)
+ self.assertEqual(combined.blocks[0].alias, 'a')
+ self.assertEqual(combined.blocks[0].names, ('a', ))
- def test_add_options_different_parser(self):
- left = core.Options(
- parser_class=object()
+ def test_add_options_blocks_second(self):
+ options1 = core.Options(
+ arguments.Argument('first'),
)
- right = core.Options(
- parser_class=object()
+ options2 = core.Options(
+ arguments.Argument('second'),
+ blocks=['a']
)
- self.assertRaises(TypeError, operator.add, left, right)
+ combined = options1 + options2
+ self.assertEqual(len(combined.blocks), 1, combined.blocks)
+ self.assertEqual(combined.blocks[0].alias, 'a')
+ self.assertEqual(combined.blocks[0].names, ('a', ))
def test_add_options_blocks_both(self):
- left = core.Options(
- blocks=['leftblock']
+ options1 = core.Options(
+ arguments.Argument('first'),
+ blocks=['a'],
)
- right = core.Options(
- blocks=['rightblock']
+ options2 = core.Options(
+ arguments.Argument('second'),
+ blocks=['a']
+ )
+ self.assertRaises(
+ ValueError,
+ operator.add,
+ options1,
+ options2,
)
- self.assertRaises(TypeError, operator.add, left, right)
- def test_add_options_to_something_else(self):
- options = core.Options()
- self.assertRaises(TypeError, operator.add, options, 1)
+ def test_add_options_not_options(self):
+ options = core.Options(
+ arguments.Argument('first'),
+ )
+ self.assertRaises(
+ TypeError,
+ operator.add,
+ options,
+ 1
+ )
+
+ def test_add_options_custom_parser_same(self):
+ class CustomParser(parser.Parser):
+ def parse_blocks(self):
+ return
+
+ options1 = core.Options(
+ parser_class=CustomParser,
+ )
+ options2 = core.Options(
+ parser_class=CustomParser,
+ )
+ combined = options1 + options2
+ self.assertIs(combined.parser_class, CustomParser)
+
+ def test_add_options_custom_parser_different(self):
+ class CustomParser(parser.Parser):
+ def parse_blocks(self):
+ return
+
+ options1 = core.Options(
+ parser_class=CustomParser,
+ )
+ options2 = core.Options(
+ parser_class=parser.Parser,
+ )
+ self.assertRaises(
+ ValueError,
+ operator.add,
+ options1,
+ options2,
+ )
+
+ def test_repr(self):
+ options = core.Options(
+ arguments.Argument('first'),
+ 'breakpoint',
+ arguments.Flag('flag', true_values=['yes']),
+ blocks=['block']
+ )
+ self.assertEqual(
+ repr(options),
+ '<Options:<Argument: first>,breakpoint,<Flag: flag>;block>'
+ )
def test_flatten_context(self):
context = Context({'foo': 'bar'})
diff --git a/docs/changes.rst b/docs/changes.rst
index b58d0fd..bfe1c76 100644
--- a/docs/changes.rst
+++ b/docs/changes.rst
@@ -4,6 +4,13 @@ Changelog
*****
+0.8.0
+*****
+
+* Removed Python 2.6 support. Supported versions are now 2.7, 3.3, 3.4 and 3.5.
+* Added support for Django 1.10.
+
+*****
0.7.2
*****
diff --git a/docs/installation.rst b/docs/installation.rst
index cf0f1c7..2a87088 100644
--- a/docs/installation.rst
+++ b/docs/installation.rst
@@ -9,6 +9,7 @@ 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-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 both Python 2.7 and Python 3.3 (or higher).
+django-classy-tags supports Python 2.7, 3.3, 3.4 and 3.5.
diff --git a/runtests.py b/runtests.py
index 9d80309..ff67c4f 100644
--- a/runtests.py
+++ b/runtests.py
@@ -32,6 +32,17 @@ else:
ROOT_URLCONF = 'runtests'
+TEMPLATES = [
+ {
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'APP_DIRS': True,
+ 'DIRS': TEMPLATE_DIRS,
+ 'OPTIONS': {
+ 'debug': TEMPLATE_DEBUG,
+ },
+ },
+]
+
def main():
import django
from django.conf import settings
@@ -43,6 +54,7 @@ def main():
TEMPLATE_DIRS = TEMPLATE_DIRS,
TEMPLATE_DEBUG = TEMPLATE_DEBUG,
MIDDLEWARE_CLASSES = [],
+ TEMPLATES=TEMPLATES,
)
# Run the test suite, including the extra validation tests.
diff --git a/setup.py b/setup.py
index a501651..cb515c4 100644
--- a/setup.py
+++ b/setup.py
@@ -22,7 +22,6 @@ setup(
"Intended Audience :: Developers",
"Natural Language :: English",
"Operating System :: OS Independent",
- "Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-classy-tags.git
More information about the Python-modules-commits
mailing list