Commits

Andy Mikhailenko  committed aff777f

Add tox. Support Python 3.3. Drop support for Python 2.4. Drop previously deprecated stuff.

  • Participants
  • Parent commits a26b998

Comments (0)

Files changed (6)

 ~$
 \.py[co]$
 ^coverage/
+^\.tox/
+^\.ropeproject/
 
 
 #eclipse files

File autoslug/__init__.py

 #  Software Foundation. See the file README for copying conditions.
 #
 
-from fields import AutoSlugField
+from autoslug.fields import AutoSlugField
 
 __all__ = ['AutoSlugField']

File autoslug/fields.py

 #  Software Foundation. See the file README for copying conditions.
 #
 
-# python
-from warnings import warn
-
 # django
 from django.db.models.fields import SlugField
 
 
 # this app
 from autoslug.settings import slugify
-import utils
+from autoslug import utils
 
 
 __all__ = ['AutoSlugField']
 
 SLUG_INDEX_SEPARATOR = '-'    # the "-" in "foo-2"
 
+try:                 # pragma: nocover
+    # Python 2.x
+    basestring
+except NameError:    # pragma: nocover
+    # Python 3.x
+    basestring = str
+
 
 class AutoSlugField(SlugField):
     """
 
         self.index_sep = kwargs.pop('sep', SLUG_INDEX_SEPARATOR)
 
-        # backward compatibility
-        if kwargs.get('unique_with_date'):
-            warn('Using unique_with_date="foo" in AutoSlugField is deprecated, '
-                 'use unique_with=("foo",) instead.', DeprecationWarning)
-            self.unique_with += (kwargs['unique_with_date'],)
-
         if self.unique_with:
             # we will do "manual" granular check below
             kwargs['unique'] = False
         if self.always_update or (self.populate_from and not value):
             value = utils.get_prepopulated_value(self, instance)
 
+            # pragma: nocover
             if __debug__ and not value and not self.blank:
-                print 'Failed to populate slug %s.%s from %s' % \
-                    (instance._meta.object_name, self.name, self.populate_from)
+                print('Failed to populate slug %s.%s from %s' % \
+                    (instance._meta.object_name, self.name, self.populate_from))
 
         if value:
             slug = self.slugify(value)

File run_tests.py

 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 import os
+import sys
 from django.conf import settings
 from django.core.management import call_command
 
 
-settings.configure(
-    INSTALLED_APPS=('autoslug', 'django_coverage'),
-    DATABASE_ENGINE='sqlite3',
-    AUTOSLUG_SLUGIFY_FUNCTION='django.template.defaultfilters.slugify',
-    COVERAGE_REPORT_HTML_OUTPUT_DIR = os.path.join('.', 'coverage')
+
+conf = dict(
+    INSTALLED_APPS = ['autoslug'],
+    DATABASES = dict(
+        default = dict(
+            ENGINE='django.db.backends.sqlite3',
+        ),
+    ),
+    AUTOSLUG_SLUGIFY_FUNCTION = 'django.template.defaultfilters.slugify',
 )
 
+# django-coverage does not support Python 3 yet
+if sys.version < '3.0':
+    conf['INSTALLED_APPS'].append('django_coverage')
+    conf.update(COVERAGE_REPORT_HTML_OUTPUT_DIR = os.path.join('.', 'coverage'))
+    test_command = 'test_coverage'
+else:
+    test_command = 'test'
+
+
+settings.configure(**conf)
+
+
 if __name__ == "__main__":
-    call_command('test_coverage', 'autoslug')
+    call_command(test_command, 'autoslug')
 
 setup(
     name     = 'django-autoslug',
-    version  = '1.6.1',  # also update doc/conf.py:version
+    version  = '1.7.0',  # also update doc/conf.py:version
     packages = ['autoslug'],
 
-    requires = ['python (>= 2.4)', 'django (>= 1.0)'],
+    requires = ['python (>= 2.5)', 'django (>= 1.0)'],
     # in case you want to use slugify() with support for transliteration:
     extras_require = {
         'cyrillic': 'pytils >= 0.2',
+[tox]
+envlist = py25, py26, py27, pypy, py33
+indexserver=
+default = http://pypi.python.org/simple
+testrun = http://pypi.testrun.org
+
+[testenv]
+deps=coverage
+     django
+     django-coverage
+commands=./run_tests.py []
+
+[testenv:py25]
+setenv =
+    PIP_INSECURE = 1
+deps=coverage
+     django==1.4.5
+     django-coverage