Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
upgpkg: python-django-classy-tags 3.0.1-2: Rebuild to fix issues with…
Browse files Browse the repository at this point in the history
… tests.

Switch to PEP517.
Remove unneededed packages from depends and checkdepends.
Add (backported) patch to fix support for django >= 4.1: django-cms/django-classy-tags#96
Run tests directly instead of using deprecated setuptools functionality: django-cms/django-classy-tags#95
Remove unnecessary quotes and curly braces.

git-svn-id: file:///srv/repos/svn-community/svn@1355404 9fca08f4-af9d-4005-b8df-a31f2cc04f65
  • Loading branch information
dvzrv authored and svntogit committed Nov 30, 2022
1 parent 406303e commit fbddd38
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 16 deletions.
41 changes: 25 additions & 16 deletions trunk/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,41 @@
_name=django-classy-tags
pkgname=python-django-classy-tags
pkgver=3.0.1
pkgrel=1
pkgrel=2
pkgdesc="Class based template tags for django"
arch=(any)
url="https://github.com/django-cms/django-classy-tags"
license=(BSD)
depends=(python-django python-six)
makedepends=(python-setuptools)
checkdepends=(python-coverage python-pytest)
source=("https://files.pythonhosted.org/packages/source/${_name::1}/${_name}/${_name}-${pkgver}.tar.gz")
sha512sums=('3d207cb398c44d058fbcc9d30dddf7cef22938b0731409fafea8776e7c5b7e59e3c8740e119a8fb6e46e5f7d2d64dd54afbdf57755c2f4c03457c6b47a0890aa')
b2sums=('67fed2308a6b50bfd0cecdf60dca7680f69cc7cfe201eceed32500b7964f3a537c11e5e676d9dbfe11535f8bde7d06bead2da9f0ef2a6e3a04783619955d233b')
depends=(python-django)
makedepends=(python-build python-installer python-setuptools python-wheel)
source=(
https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz
$pkgname-django4.1.patch
)
sha512sums=('3d207cb398c44d058fbcc9d30dddf7cef22938b0731409fafea8776e7c5b7e59e3c8740e119a8fb6e46e5f7d2d64dd54afbdf57755c2f4c03457c6b47a0890aa'
'1e2d4bfdbdb46c1f4efa1ff5059fa00cceadb96f730a04b19de5d27be3cb4b509a5790580284a71912c128b91501241ea9887e307c8921d9ffe1650a84a985e4')
b2sums=('67fed2308a6b50bfd0cecdf60dca7680f69cc7cfe201eceed32500b7964f3a537c11e5e676d9dbfe11535f8bde7d06bead2da9f0ef2a6e3a04783619955d233b'
'97df3d5bbefc8464e59bc6ff960a6a622315710e884eb4fe831d22686b0dba8855f3e41d543759967152843551bed32662c0818c3cfc1c09718314d379494e24')

prepare() {
# compatibility with django >= 4.1: https://github.com/django-cms/django-classy-tags/issues/96
patch -Np1 -d $_name-$pkgver -i ../$pkgname-django4.1.patch
}

build() {
cd "${_name}-${pkgver}"
python setup.py build
cd $_name-$pkgver
python -m build --wheel --no-isolation
}

check() {
cd "${_name}-${pkgver}"
export PYTHONPATH="build:${PYTHONPATH}"
python setup.py test
cd $_name-$pkgver
export PYTHONPATH="$PWD/build/lib:$PYTHONPATH"
python tests/settings.py
}

package() {
cd "${_name}-${pkgver}"
python setup.py install --optimize=1 --root="${pkgdir}"
install -vDm 644 README.rst -t "${pkgdir}/usr/share/doc/${pkgname}"
install -vDm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
cd $_name-$pkgver
python -m installer --destdir="$pkgdir" dist/*.whl
install -vDm 644 README.rst -t "$pkgdir/usr/share/doc/$pkgname/"
install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"
}
95 changes: 95 additions & 0 deletions trunk/python-django-classy-tags-django4.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
diff --git a/classytags/core.py b/classytags/core.py
index 9a991e1..8190e40 100644
--- a/classytags/core.py
+++ b/classytags/core.py
@@ -108,22 +108,13 @@ def parse(self, parser, tokens):
class TagMeta(type):
"""
Metaclass for the Tag class that set's the name attribute onto the class
- and a _decorated_function pseudo-function which is used by Django's
- template system to get the tag name.
"""
def __new__(cls, name, bases, attrs):
- parents = [base for base in bases if isinstance(base, TagMeta)]
- if not parents:
+ if not any(base for base in bases if isinstance(base, TagMeta)):
return super().__new__(cls, name, bases, attrs)
tag_name = str(attrs.get('name', get_default_name(name)))
-
- def fake_func():
- pass # pragma: no cover
-
- fake_func.__name__ = tag_name
- attrs['_decorated_function'] = fake_func
- attrs['name'] = str(tag_name)
- return super().__new__(cls, name, bases, attrs)
+ attrs['name'] = tag_name
+ return super().__new__(cls, tag_name, bases, attrs)


class Tag(TagMeta('TagMeta', (Node,), {})):
diff --git a/setup.py b/setup.py
index 212157e..c8c7d43 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@


REQUIREMENTS = [
- 'django>=2.2',
+ 'django>=3.2',
]


@@ -21,10 +21,9 @@
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Framework :: Django',
- 'Framework :: Django :: 2.2',
- 'Framework :: Django :: 3.1',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
+ 'Framework :: Django :: 4.1',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development',
diff --git a/tests/test_core.py b/tests/test_core.py
index e1cc8ae..13d6a2e 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -591,6 +591,22 @@ class MyTag2(core.Tag):
msg = "'my_tag2' in %s" % lib.tags.keys()
self.assertTrue('my_tag2' not in lib.tags, msg)

+ # test decorated naming
+ lib = template.Library()
+
+ @lib.tag(name="my_decorated_tag_5")
+ class MyTag5(core.Tag):
+ pass
+ msg = "'my_decorated_tag_5' not in %s" % lib.tags.keys()
+ self.assertTrue('my_decorated_tag_5' in lib.tags, msg)
+
+ # test decorated and explicit naming
+ # the tag registration takes precedence over the name attribute
+ lib = template.Library()
+ lib.tag('my_decorated_tag_6', MyTag2)
+ msg = "'my_decorated_tag_6' not in %s" % lib.tags.keys()
+ self.assertTrue('my_decorated_tag_6' in lib.tags, msg)
+
def test_hello_world(self):
class Hello(core.Tag):
options = core.Options(
@@ -971,6 +987,12 @@ class MyTag(core.Tag):
tag = MyTag(dummy_parser, DummyTokens())
self.assertEqual('<Tag: mytag>', repr(tag))

+ def test_repr_without_explicit_name(self):
+ class MyTag(core.Tag):
+ pass
+ tag = MyTag(dummy_parser, DummyTokens())
+ self.assertEqual('<Tag: my_tag>', repr(tag))
+
def test_non_required_multikwarg(self):
options = core.Options(
arguments.MultiKeywordArgument('multi', required=False),

0 comments on commit fbddd38

Please sign in to comment.