Skip to content

Commit

Permalink
Fixed warnings in the testsuite.
Browse files Browse the repository at this point in the history
  • Loading branch information
apollo13 committed Jul 27, 2014
1 parent 3d15236 commit 9491a50
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 20 deletions.
16 changes: 11 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ python:
- "2.7"
- "3.2"
- "3.3"
- "3.4"

env:
- DJANGO=https://github.com/django/django/archive/master.tar.gz
- DJANGO=https://github.com/django/django/archive/stable/1.6.x.tar.gz
- DJANGO=django==1.5.2
- DJANGO=django==1.4.6
- DJANGO=https://github.com/django/django/archive/stable/1.7.x.tar.gz
- DJANGO=django==1.6.5
- DJANGO=django==1.5.8
- DJANGO=django==1.4.13

install:
- pip install $DJANGO
Expand All @@ -26,9 +28,13 @@ notifications:
matrix:
exclude:
- python: "3.2"
env: DJANGO=django==1.4.6
env: DJANGO=django==1.4.13
- python: "3.3"
env: DJANGO=django==1.4.6
env: DJANGO=django==1.4.13
- python: "3.4"
env: DJANGO=django==1.4.13
- python: "2.6"
env: DJANGO=https://github.com/django/django/archive/stable/1.7.x.tar.gz
- python: "2.6"
env: DJANGO=https://github.com/django/django/archive/master.tar.gz

14 changes: 10 additions & 4 deletions django_filters/filterset.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from django.db.models.fields import FieldDoesNotExist
from django.db.models.related import RelatedObject
from django.utils import six
from django.utils.datastructures import SortedDict
from django.utils.text import capfirst
from django.utils.translation import ugettext as _

Expand All @@ -19,6 +18,13 @@
# Django < 1.5 fallback
from django.db.models.sql.constants import LOOKUP_SEP # noqa

try:
from collections import OrderedDict
except ImportError: # pragma: nocover
# Django < 1.5 fallback
from django.utils.datastructures import SortedDict as OrderedDict # noqa


from .filters import (Filter, CharFilter, BooleanFilter,
ChoiceFilter, DateFilter, DateTimeFilter, TimeFilter, ModelChoiceFilter,
ModelMultipleChoiceFilter, NumberFilter)
Expand Down Expand Up @@ -46,7 +52,7 @@ def get_declared_filters(bases, attrs, with_base_filters=True):
if hasattr(base, 'declared_filters'):
filters = list(base.declared_filters.items()) + filters

return SortedDict(filters)
return OrderedDict(filters)


def get_model_field(model, f):
Expand All @@ -72,7 +78,7 @@ def get_model_field(model, f):

def filters_for_model(model, fields=None, exclude=None, filter_for_field=None,
filter_for_reverse_field=None):
field_dict = SortedDict()
field_dict = OrderedDict()
opts = model._meta
if fields is None:
fields = [f.name for f in sorted(opts.fields + opts.many_to_many)
Expand Down Expand Up @@ -310,7 +316,7 @@ def count(self):
@property
def form(self):
if not hasattr(self, '_form'):
fields = SortedDict([
fields = OrderedDict([
(name, filter_.field)
for name, filter_ in six.iteritems(self.filters)])
fields[self.order_by_field] = self.ordering_field
Expand Down
5 changes: 4 additions & 1 deletion runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

if not settings.configured:
test_runners_args = {}
if VERSION[1] < 6:
if VERSION < (1, 6):
test_runners_args = {
'TEST_RUNNER': 'discover_runner.DiscoverRunner',
}
Expand All @@ -18,12 +18,15 @@
},
},
INSTALLED_APPS=(
'django.contrib.contenttypes',
'django.contrib.auth',
'django_filters',
'tests',
),
ROOT_URLCONF=None,
USE_TZ=True,
SECRET_KEY='foobar',
SILENCED_SYSTEM_CHECKS=['1_7.W001'],
**test_runners_args
)

Expand Down
10 changes: 5 additions & 5 deletions tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Meta:


class Restaurant(Place):
serves_pizza = models.BooleanField()
serves_pizza = models.BooleanField(default=False)


class NetworkSetting(models.Model):
Expand Down Expand Up @@ -131,14 +131,14 @@ def __str__(self):

class Account(models.Model):
name = models.CharField(max_length=100)
in_good_standing = models.BooleanField()
friendly = models.BooleanField()
in_good_standing = models.BooleanField(default=False)
friendly = models.BooleanField(default=False)


class Profile(models.Model):
account = models.OneToOneField(Account, related_name='profile')
likes_coffee = models.BooleanField()
likes_tea = models.BooleanField()
likes_coffee = models.BooleanField(default=False)
likes_tea = models.BooleanField(default=False)


class BankAccount(Account):
Expand Down
7 changes: 6 additions & 1 deletion tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
from __future__ import unicode_literals

import decimal
import sys

if sys.version_info >= (2, 7):
import unittest
else: # pragma: nocover
from django.utils import unittest # noqa

import django
from django import forms
from django.utils import unittest
from django.test import TestCase

from django_filters.widgets import RangeWidget
Expand Down
9 changes: 7 additions & 2 deletions tests/test_filtering.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
from __future__ import absolute_import
from __future__ import unicode_literals

import mock
import datetime
import mock
import sys

if sys.version_info >= (2, 7):
import unittest
else: # pragma: nocover
from django.utils import unittest # noqa

from django.utils import unittest
from django.test import TestCase
from django.utils import six
from django.utils.timezone import now
Expand Down
7 changes: 6 additions & 1 deletion tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
from __future__ import unicode_literals

import mock
import sys

if sys.version_info >= (2, 7):
import unittest
else: # pragma: nocover
from django.utils import unittest # noqa

from django import forms
from django.utils import unittest
from django.test import TestCase

from django_filters.fields import Lookup
Expand Down
7 changes: 6 additions & 1 deletion tests/test_filterset.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
from __future__ import absolute_import, unicode_literals

import mock
import sys

if sys.version_info >= (2, 7):
import unittest
else: # pragma: nocover
from django.utils import unittest # noqa

from django.db import models
from django.utils import unittest
from django.test import TestCase

from django_filters.filterset import FilterSet
Expand Down

0 comments on commit 9491a50

Please sign in to comment.