From 80000afcd14b66dc9858ac5efd64393fc4b6db25 Mon Sep 17 00:00:00 2001 From: Mjumbe Wawatu Ukweli Date: Sun, 2 Feb 2014 17:23:21 -0500 Subject: [PATCH 1/8] Use django.conf.urls instead of deprecated django.conf.urls.defaults --- extra_views/tests/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra_views/tests/urls.py b/extra_views/tests/urls.py index b52ec82..70b10a9 100644 --- a/extra_views/tests/urls.py +++ b/extra_views/tests/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import patterns +from django.conf.urls import patterns from django.views.generic import TemplateView from .formsets import AddressFormSet from .views import AddressFormSetView, AddressFormSetViewNamed, ItemModelFormSetView, \ From bbf05b4874748522aecd3cbac9be57f9ac2f5382 Mon Sep 17 00:00:00 2001 From: Mjumbe Wawatu Ukweli Date: Sun, 2 Feb 2014 17:38:50 -0500 Subject: [PATCH 2/8] Convert sort_fields_aliases parameter in SortHelper to a list In Python3, since zip returns a generator, we need to create a list so that we can iterate through sort_fields_aliases multiple times --- extra_views/contrib/mixins.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extra_views/contrib/mixins.py b/extra_views/contrib/mixins.py index b40304f..eb6465f 100644 --- a/extra_views/contrib/mixins.py +++ b/extra_views/contrib/mixins.py @@ -92,6 +92,10 @@ def get_queryset(self): class SortHelper(object): def __init__(self, request, sort_fields_aliases, sort_param_name, sort_type_param_name): + # Create a list from sort_fields_aliases, in case it is a generator, + # since we want to iterate through it multiple times. + sort_fields_aliases = list(sort_fields_aliases) + self.initial_params = request.GET.copy() self.sort_fields = dict(sort_fields_aliases) self.inv_sort_fields = dict((v, k) for k, v in sort_fields_aliases) From 11e9c8757e5ab5dcac0b43372d0dec7420937acd Mon Sep 17 00:00:00 2001 From: Mjumbe Wawatu Ukweli Date: Sun, 2 Feb 2014 17:39:14 -0500 Subject: [PATCH 3/8] Add Python 3.3 and Django 1.6 to the Travis file --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 83472d4..3d8367a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,9 @@ python: - 2.6 - 2.7 - 3.2 + - 3.3 env: + - DJANGO_VERSION=1.6.1 - DJANGO_VERSION=1.5.1 - DJANGO_VERSION=1.4.3 install: From 57b44d65b0af05639a5310a3b49df73940ff0318 Mon Sep 17 00:00:00 2001 From: Mjumbe Wawatu Ukweli Date: Sun, 2 Feb 2014 17:43:59 -0500 Subject: [PATCH 4/8] Update versions of Django 1.4 and 1.5 tested continuously --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3d8367a..c538cbe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,8 @@ python: - 3.3 env: - DJANGO_VERSION=1.6.1 - - DJANGO_VERSION=1.5.1 - - DJANGO_VERSION=1.4.3 + - DJANGO_VERSION=1.5.5 + - DJANGO_VERSION=1.4.10 install: - pip install -q -r requirements.txt --use-mirrors - pip install coveralls --use-mirrors From ca1094c7d7a833f6455b8e680a816fd82240f266 Mon Sep 17 00:00:00 2001 From: Mjumbe Wawatu Ukweli Date: Sun, 2 Feb 2014 18:11:13 -0500 Subject: [PATCH 5/8] Update developemnt dependency versions in requirements.txt --- requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 11b9a81..b6eb5eb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ Django>=1.3 -coverage==3.6 +coverage==3.7.1 nose-progressive==1.5 django-nose==1.2 -pinocchio==0.3.1 -six==1.3.0 \ No newline at end of file +pinocchio==0.4.1 +six==1.5.2 \ No newline at end of file From 7d6b5cd9d84ba488032784500998d69dd418bc33 Mon Sep 17 00:00:00 2001 From: Mjumbe Wawatu Ukweli Date: Sun, 2 Feb 2014 17:43:59 -0500 Subject: [PATCH 6/8] Update versions of Django 1.4 and 1.5 tested continuously From abe9fb59214750ba3ad3839127d8d24c5e15e549 Mon Sep 17 00:00:00 2001 From: Mjumbe Wawatu Ukweli Date: Sun, 2 Feb 2014 18:37:40 -0500 Subject: [PATCH 7/8] Exclude Python 3/Django 1.4 in Travis test matrix --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index c538cbe..7ac60b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,3 +15,9 @@ install: script: coverage run runtests.py --with-spec after_success: - coveralls --verbose +matrix: + exclude: + - python: 3.2 + env: DJANGO_VERSION=1.4.10 + - python: 3.3 + env: DJANGO_VERSION=1.4.10 From 392295d969c88df023aeac46be64f045f48f6432 Mon Sep 17 00:00:00 2001 From: Mjumbe Wawatu Ukweli Date: Sun, 2 Feb 2014 19:05:32 -0500 Subject: [PATCH 8/8] Use unicode_literals from __future__ --- extra_views/contrib/mixins.py | 4 +- extra_views/dates.py | 18 +++---- extra_views/tests/tests.py | 90 ++++++++++++++++++----------------- 3 files changed, 59 insertions(+), 53 deletions(-) diff --git a/extra_views/contrib/mixins.py b/extra_views/contrib/mixins.py index eb6465f..3d758fe 100644 --- a/extra_views/contrib/mixins.py +++ b/extra_views/contrib/mixins.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import datetime import functools import operator @@ -50,7 +52,7 @@ def get_search_fields_with_filters(self): fields.append((sf, 'icontains', )) else: if self.check_lookups and sf[1] not in VALID_STRING_LOOKUPS: - raise ValueError(u'Invalid string lookup - %s' % sf[1]) + raise ValueError('Invalid string lookup - %s' % sf[1]) fields.append(sf) return fields diff --git a/extra_views/dates.py b/extra_views/dates.py index 36a775c..c6cfca0 100644 --- a/extra_views/dates.py +++ b/extra_views/dates.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + from calendar import Calendar from collections import defaultdict import datetime @@ -10,13 +12,13 @@ from django.utils.translation import ugettext_lazy as _ DAYS = ( - _(u'Monday'), - _(u'Tuesday'), - _(u'Wednesday'), - _(u'Thursday'), - _(u'Friday'), - _(u'Saturday'), - _(u'Sunday'), + _('Monday'), + _('Tuesday'), + _('Wednesday'), + _('Thursday'), + _('Friday'), + _('Saturday'), + _('Sunday'), ) @@ -39,7 +41,7 @@ class BaseCalendarMonthView(DateMixin, YearMixin, MonthMixin, BaseListView): def get_paginate_by(self, queryset): if self.paginate_by is not None: - raise ImproperlyConfigured(u"'%s' cannot be paginated, it is a calendar view" % self.__class__.__name__) + raise ImproperlyConfigured("'%s' cannot be paginated, it is a calendar view" % self.__class__.__name__) return None def get_allow_future(self): diff --git a/extra_views/tests/tests.py b/extra_views/tests/tests.py index aa410d9..2a2f572 100644 --- a/extra_views/tests/tests.py +++ b/extra_views/tests/tests.py @@ -1,3 +1,5 @@ +from __future__ import unicode_literals + import datetime from decimal import Decimal as D @@ -12,9 +14,9 @@ class FormSetViewTests(TransactionTestCase): urls = 'extra_views.tests.urls' management_data = { - 'form-TOTAL_FORMS': u'2', - 'form-INITIAL_FORMS': u'0', - 'form-MAX_NUM_FORMS': u'', + 'form-TOTAL_FORMS': '2', + 'form-INITIAL_FORMS': '0', + 'form-MAX_NUM_FORMS': '', } def test_create(self): @@ -49,11 +51,11 @@ def test_success_url(self): def test_invalid(self): data = { - 'form-0-name': u'Joe Bloggs', - 'form-0-city': u'', - 'form-0-line1': u'', - 'form-0-line2': u'', - 'form-0-postcode': u'', + 'form-0-name': 'Joe Bloggs', + 'form-0-city': '', + 'form-0-line1': '', + 'form-0-line2': '', + 'form-0-postcode': '', } data.update(self.management_data) @@ -69,9 +71,9 @@ def test_formset_class(self): class ModelFormSetViewTests(TransactionTestCase): urls = 'extra_views.tests.urls' management_data = { - 'form-TOTAL_FORMS': u'2', - 'form-INITIAL_FORMS': u'0', - 'form-MAX_NUM_FORMS': u'', + 'form-TOTAL_FORMS': '2', + 'form-INITIAL_FORMS': '0', + 'form-MAX_NUM_FORMS': '', } def test_create(self): @@ -101,7 +103,7 @@ def test_post(self): 'form-0-status': 0, } data.update(self.management_data) - data['form-TOTAL_FORMS'] = u'1' + data['form-TOTAL_FORMS'] = '1' res = self.client.post('/modelformset/simple/', data, follow=True) self.assertEqual(res.status_code, 200) self.assertEquals(Item.objects.all().count(), 1) @@ -122,9 +124,9 @@ def test_context(self): class InlineFormSetViewTests(TransactionTestCase): urls = 'extra_views.tests.urls' management_data = { - 'items-TOTAL_FORMS': u'2', - 'items-INITIAL_FORMS': u'0', - 'items-MAX_NUM_FORMS': u'', + 'items-TOTAL_FORMS': '2', + 'items-INITIAL_FORMS': '0', + 'items-MAX_NUM_FORMS': '', } def test_create(self): @@ -213,7 +215,7 @@ def test_post(self): data = { 'tests-tag-content_type-object_id-TOTAL_FORMS': 3, 'tests-tag-content_type-object_id-INITIAL_FORMS': 1, - 'tests-tag-content_type-object_id-MAX_NUM_FORMS': u'', + 'tests-tag-content_type-object_id-MAX_NUM_FORMS': '', 'tests-tag-content_type-object_id-0-name': 'Updated', 'tests-tag-content_type-object_id-0-id': 1, 'tests-tag-content_type-object_id-1-DELETE': True, @@ -235,7 +237,7 @@ def test_post2(self): data = { 'tests-tag-content_type-object_id-TOTAL_FORMS': 3, 'tests-tag-content_type-object_id-INITIAL_FORMS': 1, - 'tests-tag-content_type-object_id-MAX_NUM_FORMS': u'', + 'tests-tag-content_type-object_id-MAX_NUM_FORMS': '', 'tests-tag-content_type-object_id-0-name': 'Updated', 'tests-tag-content_type-object_id-0-id': 1, 'tests-tag-content_type-object_id-1-name': 'Tag 2', @@ -256,20 +258,20 @@ def test_create(self): self.assertEquals(0, Tag.objects.count()) data = { - 'name': u'Dummy Order', - 'items-TOTAL_FORMS': u'2', - 'items-INITIAL_FORMS': u'0', - 'items-MAX_NUM_FORMS': u'', + 'name': 'Dummy Order', + 'items-TOTAL_FORMS': '2', + 'items-INITIAL_FORMS': '0', + 'items-MAX_NUM_FORMS': '', 'items-0-name': 'Bubble Bath', 'items-0-sku': '1234567890123', 'items-0-price': D('9.99'), 'items-0-status': 0, - 'items-0-order': u'', + 'items-0-order': '', 'items-1-DELETE': True, 'tests-tag-content_type-object_id-TOTAL_FORMS': 2, 'tests-tag-content_type-object_id-INITIAL_FORMS': 0, - 'tests-tag-content_type-object_id-MAX_NUM_FORMS': u'', - 'tests-tag-content_type-object_id-0-name': u'Test', + 'tests-tag-content_type-object_id-MAX_NUM_FORMS': '', + 'tests-tag-content_type-object_id-0-name': 'Test', 'tests-tag-content_type-object_id-1-DELETE': True, } @@ -289,9 +291,9 @@ def test_named_create(self): def test_validation(self): data = { - 'items-TOTAL_FORMS': u'2', - 'items-INITIAL_FORMS': u'0', - 'items-MAX_NUM_FORMS': u'', + 'items-TOTAL_FORMS': '2', + 'items-INITIAL_FORMS': '0', + 'items-MAX_NUM_FORMS': '', 'items-0-name': 'Test Item 1', 'items-0-sku': '', 'items-0-price': '', @@ -305,8 +307,8 @@ def test_validation(self): 'items-1-DELETE': True, 'tests-tag-content_type-object_id-TOTAL_FORMS': 2, 'tests-tag-content_type-object_id-INITIAL_FORMS': 0, - 'tests-tag-content_type-object_id-MAX_NUM_FORMS': u'', - 'tests-tag-content_type-object_id-0-name': u'Test', + 'tests-tag-content_type-object_id-MAX_NUM_FORMS': '', + 'tests-tag-content_type-object_id-0-name': 'Test', 'tests-tag-content_type-object_id-1-DELETE': True, } @@ -334,10 +336,10 @@ def test_update(self): self.assertEquals('Item 0', order.items.all()[0].name) data = { - 'name': u'Dummy Order', - 'items-TOTAL_FORMS': u'4', - 'items-INITIAL_FORMS': u'2', - 'items-MAX_NUM_FORMS': u'', + 'name': 'Dummy Order', + 'items-TOTAL_FORMS': '4', + 'items-INITIAL_FORMS': '2', + 'items-MAX_NUM_FORMS': '', 'items-0-name': 'Bubble Bath', 'items-0-sku': '1234567890123', 'items-0-price': D('9.99'), @@ -358,12 +360,12 @@ def test_update(self): 'items-3-DELETE': True, 'tests-tag-content_type-object_id-TOTAL_FORMS': 3, 'tests-tag-content_type-object_id-INITIAL_FORMS': 1, - 'tests-tag-content_type-object_id-MAX_NUM_FORMS': u'', - 'tests-tag-content_type-object_id-0-name': u'Test', + 'tests-tag-content_type-object_id-MAX_NUM_FORMS': '', + 'tests-tag-content_type-object_id-0-name': 'Test', 'tests-tag-content_type-object_id-0-id': 1, 'tests-tag-content_type-object_id-0-DELETE': True, - 'tests-tag-content_type-object_id-1-name': u'Test 2', - 'tests-tag-content_type-object_id-2-name': u'Test 3', + 'tests-tag-content_type-object_id-1-name': 'Test 2', + 'tests-tag-content_type-object_id-2-name': 'Test 3', } res = self.client.post('/inlines/1/', data, follow=True) @@ -380,13 +382,13 @@ def test_parent_instance_saved_in_form_save(self): order.save() data = { - 'name': u'Dummy Order', - 'items-TOTAL_FORMS': u'0', - 'items-INITIAL_FORMS': u'0', - 'items-MAX_NUM_FORMS': u'', - 'tests-tag-content_type-object_id-TOTAL_FORMS': u'0', - 'tests-tag-content_type-object_id-INITIAL_FORMS': u'0', - 'tests-tag-content_type-object_id-MAX_NUM_FORMS': u'', + 'name': 'Dummy Order', + 'items-TOTAL_FORMS': '0', + 'items-INITIAL_FORMS': '0', + 'items-MAX_NUM_FORMS': '', + 'tests-tag-content_type-object_id-TOTAL_FORMS': '0', + 'tests-tag-content_type-object_id-INITIAL_FORMS': '0', + 'tests-tag-content_type-object_id-MAX_NUM_FORMS': '', } res = self.client.post('/inlines/1/', data, follow=True)