From da2c0ef2b0627757edc8117da9f64fb9ca5038da Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 10 Nov 2026 14:26:43 +0100 Subject: [PATCH] Make tests run again. Test for up to Django 6.1. Revert reading page_suffix from context, it messed up multiple paginators case. --- fnp_django_pagination/__init__.py | 3 -- .../templatetags/pagination_tags.py | 6 +-- .../test_project/settings.py | 54 ------------------- .../tests/runner.py => runtests.py | 2 +- setup.py | 9 +--- .../test_project => test_project}/__init__.py | 0 .../example/__init__.py | 0 .../example/models.py | 0 .../example/templates/example/list.html | 0 .../example/templates/example/two_lists.html | 0 .../pagination/custom_pagination.html | 0 .../example/urls.py | 0 .../example/views.py | 0 .../test_project => test_project}/manage.py | 0 .../tests => test_project}/settings.py | 0 .../test_project => test_project}/tests.py | 0 .../test_project => test_project}/urls.py | 0 tox.ini | 25 +++++---- 18 files changed, 21 insertions(+), 78 deletions(-) delete mode 100644 fnp_django_pagination/test_project/settings.py rename fnp_django_pagination/tests/runner.py => runtests.py (77%) rename {fnp_django_pagination/test_project => test_project}/__init__.py (100%) rename {fnp_django_pagination/test_project => test_project}/example/__init__.py (100%) rename {fnp_django_pagination/test_project => test_project}/example/models.py (100%) rename {fnp_django_pagination/test_project => test_project}/example/templates/example/list.html (100%) rename {fnp_django_pagination/test_project => test_project}/example/templates/example/two_lists.html (100%) rename {fnp_django_pagination/test_project => test_project}/example/templates/pagination/custom_pagination.html (100%) rename {fnp_django_pagination/test_project => test_project}/example/urls.py (100%) rename {fnp_django_pagination/test_project => test_project}/example/views.py (100%) rename {fnp_django_pagination/test_project => test_project}/manage.py (100%) rename {fnp_django_pagination/tests => test_project}/settings.py (100%) rename {fnp_django_pagination/test_project => test_project}/tests.py (100%) rename {fnp_django_pagination/test_project => test_project}/urls.py (100%) diff --git a/fnp_django_pagination/__init__.py b/fnp_django_pagination/__init__.py index 1b7390c..1f05a51 100644 --- a/fnp_django_pagination/__init__.py +++ b/fnp_django_pagination/__init__.py @@ -32,6 +32,3 @@ fnp-django-pagination is a set of utilities for creating robust pagination tools throughout a django application. """ - - -__version__ = (2, 2, 12, "final", 0) diff --git a/fnp_django_pagination/templatetags/pagination_tags.py b/fnp_django_pagination/templatetags/pagination_tags.py index ca51e40..d61e055 100644 --- a/fnp_django_pagination/templatetags/pagination_tags.py +++ b/fnp_django_pagination/templatetags/pagination_tags.py @@ -142,10 +142,8 @@ class AutoPaginateNode(Node): if self.multiple_paginations and 'multiple_paginations' not in context: context['multiple_paginations'] = True - if context.get('page_suffix'): - page_suffix = context['page_suffix'] - elif context.get('multiple_paginations') or getattr(context, "paginator", None): - page_suffix = '_%s' % self.queryset_var + if context.get('multiple_paginations') or getattr(context, "paginator", None): + page_suffix = '_%s' % self.queryset_var else: page_suffix = '' diff --git a/fnp_django_pagination/test_project/settings.py b/fnp_django_pagination/test_project/settings.py deleted file mode 100644 index 7791775..0000000 --- a/fnp_django_pagination/test_project/settings.py +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright (c) 2010, 2011 Linaro Limited -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the author nor the names of other -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -import sys -import os - -# Add this directory to path so that 'example' can be imported later -# below. Without this the runner will fail when started via ``setup.py -# test`` -sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) - -from django_testproject.settings import gen_settings - - -locals().update( - gen_settings( - INSTALLED_APPS=[ - 'example', - 'fnp_django_pagination'], - MIDDLEWARE_CLASSES=[ - 'fnp_django_pagination.middleware.PaginationMiddleware'], - TEMPLATE_CONTEXT_PROCESSORS=[ - # Request processor needs to be enabled - 'django.core.context_processors.request'], - ROOT_URLCONF="fnp_django_pagination.test_project.urls"), - TEMPLATE_LOADERS = ['django.template.loaders.app_directories.Loader'], - SECRET_KEY = 'not for production', - ) diff --git a/fnp_django_pagination/tests/runner.py b/runtests.py similarity index 77% rename from fnp_django_pagination/tests/runner.py rename to runtests.py index 4604e6b..4ab5eda 100755 --- a/fnp_django_pagination/tests/runner.py +++ b/runtests.py @@ -8,7 +8,7 @@ from django.core.management import call_command def runtests(): - os.environ['DJANGO_SETTINGS_MODULE'] = 'fnp_django_pagination.tests.settings' + os.environ['DJANGO_SETTINGS_MODULE'] = 'test_project.settings' django.setup() failures = call_command('test', 'fnp_django_pagination') diff --git a/setup.py b/setup.py index 49d9d4a..29506fd 100755 --- a/setup.py +++ b/setup.py @@ -36,17 +36,15 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'fnp_django_pagination.tests.settings' setup( name='fnp-django-pagination', - # Magic version handling with versiontools - version=":versiontools:fnp_django_pagination:__version__", + version="2.2.13", author='Zygmunt Krynicki', author_email='zygmunt.krynicki@linaro.org', description="fnp-django-pagination", long_description=open("README.rst").read(), keywords='pagination,django', url='https://github.com/fnp/django-pagination', - test_suite="fnp_django_pagination.tests.runner.runtests", license='BSD', - packages=find_packages(), + packages=find_packages(exclude=['tests*']), classifiers=[ "Development Status :: 4 - Beta", "Environment :: Web Environment", @@ -59,8 +57,5 @@ setup( "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", ], - setup_requires=[ - 'versiontools >= 1.3.1' - ], include_package_data=True, ) diff --git a/fnp_django_pagination/test_project/__init__.py b/test_project/__init__.py similarity index 100% rename from fnp_django_pagination/test_project/__init__.py rename to test_project/__init__.py diff --git a/fnp_django_pagination/test_project/example/__init__.py b/test_project/example/__init__.py similarity index 100% rename from fnp_django_pagination/test_project/example/__init__.py rename to test_project/example/__init__.py diff --git a/fnp_django_pagination/test_project/example/models.py b/test_project/example/models.py similarity index 100% rename from fnp_django_pagination/test_project/example/models.py rename to test_project/example/models.py diff --git a/fnp_django_pagination/test_project/example/templates/example/list.html b/test_project/example/templates/example/list.html similarity index 100% rename from fnp_django_pagination/test_project/example/templates/example/list.html rename to test_project/example/templates/example/list.html diff --git a/fnp_django_pagination/test_project/example/templates/example/two_lists.html b/test_project/example/templates/example/two_lists.html similarity index 100% rename from fnp_django_pagination/test_project/example/templates/example/two_lists.html rename to test_project/example/templates/example/two_lists.html diff --git a/fnp_django_pagination/test_project/example/templates/pagination/custom_pagination.html b/test_project/example/templates/pagination/custom_pagination.html similarity index 100% rename from fnp_django_pagination/test_project/example/templates/pagination/custom_pagination.html rename to test_project/example/templates/pagination/custom_pagination.html diff --git a/fnp_django_pagination/test_project/example/urls.py b/test_project/example/urls.py similarity index 100% rename from fnp_django_pagination/test_project/example/urls.py rename to test_project/example/urls.py diff --git a/fnp_django_pagination/test_project/example/views.py b/test_project/example/views.py similarity index 100% rename from fnp_django_pagination/test_project/example/views.py rename to test_project/example/views.py diff --git a/fnp_django_pagination/test_project/manage.py b/test_project/manage.py similarity index 100% rename from fnp_django_pagination/test_project/manage.py rename to test_project/manage.py diff --git a/fnp_django_pagination/tests/settings.py b/test_project/settings.py similarity index 100% rename from fnp_django_pagination/tests/settings.py rename to test_project/settings.py diff --git a/fnp_django_pagination/test_project/tests.py b/test_project/tests.py similarity index 100% rename from fnp_django_pagination/test_project/tests.py rename to test_project/tests.py diff --git a/fnp_django_pagination/test_project/urls.py b/test_project/urls.py similarity index 100% rename from fnp_django_pagination/test_project/urls.py rename to test_project/urls.py diff --git a/tox.ini b/tox.ini index 23ee964..5566ce6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,18 +1,20 @@ [tox] envlist=clear, - d{21}-py{36,37} - d{22,30,31}-py{36,37,38,39} - d32-py{36,37,38,39,310} - d40-py{38,39,310} - d41-py{38,39,310,311} - d42-py{38,39,310,311} + d{22,30,31}-py{38,39}, + d{32,40}-py{38,39,310}, + d41-py{38,39,310,311}, + d42-py{38,39,310,311,312}, + d50-py{310,311,312}, + d51-py{310,311,312,313}, + d52-py{310,311,312,313,314}, + d60-py{312,313,314}, + d61-py{312,313,314,315}, stats [testenv] -commands=coverage run --source=fnp_django_pagination --omit *runner*,*test_project* setup.py test +commands=coverage run --source=fnp_django_pagination runtests.py deps= - d20: Django>=2.0,<2.1 - d21: Django>=2.1,<2.2 + setuptools d22: Django>=2.2,<3.0 d30: Django>=3.0,<3.1 d31: Django>=3.1,<3.2 @@ -20,6 +22,11 @@ deps= d40: Django>=4.0,<4.1 d41: Django~=4.1.0 d42: Django~=4.2.0 + d50: Django~=5.0.0 + d51: Django~=5.1.0 + d52: Django~=5.2.0 + d60: Django~=6.0.0 + d61: Django~=6.1.0 coverage [testenv:clear] -- 2.20.1