diff --git a/.travis.yml b/.travis.yml index ce352f3..7c20658 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,16 @@ +sudo: false language: python python: + - "3.5" - "3.4" - "3.3" - - "3.2" - "2.7" - - "2.6" - pypy env: - - DJANGO="django==1.8.2" - - DJANGO="django==1.7.7" - - DJANGO="django==1.4.20" + - DJANGO="django==1.9" + - DJANGO="django==1.8.7" install: - pip install $DJANGO @@ -27,19 +26,10 @@ before_script: matrix: exclude: - - python: "3.4" - env: DJANGO="django==1.4.20" - python: "3.3" - env: DJANGO="django==1.4.20" - - python: "3.2" - env: DJANGO="django==1.4.20" - - python: "2.6" - env: DJANGO="django==1.7.7" - - python: "2.6" - env: DJANGO="django==1.8.2" + env: DJANGO="django==1.9" -script: - - coverage run --source=uuslug manage.py test +script: coverage run --source=uuslug manage.py test after_success: - - coveralls + coveralls diff --git a/requirements.txt b/requirements.txt index b6debb4..715cfff 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -Django>=1.4.20 +Django>=1.4+ diff --git a/setup.py b/setup.py index b969f95..b54b326 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ url = 'https://github.com/un33k/django-uuslug' author = 'Val Neekman' author_email = 'info@neekware.com' license = 'BSD' -install_requires = ['python-slugify>=1.1.3'] +install_requires = ['python-slugify>=1.1.4'] classifiers = [ 'Development Status :: 5 - Production/Stable', 'Environment :: Web Environment', @@ -63,8 +63,7 @@ if sys.argv[-1] == 'publish': os.system("python setup.py sdist upload") args = {'version': get_version(package)} print("You probably want to also tag the version now:") - print(" git tag -a %(version)s -m 'version %(version)s'" % args) - print(" git push --tags") + print(" git tag -a %(version)s -m 'version %(version)s' && git push --tags" % args) sys.exit() diff --git a/uuslug/__init__.py b/uuslug/__init__.py index c29daec..3a5f1cb 100644 --- a/uuslug/__init__.py +++ b/uuslug/__init__.py @@ -2,6 +2,6 @@ from .uuslug import * __author__ = 'Val Neekman @ Neekware Inc. [@vneekman]' __description__ = 'A Python slugify application that also handles Unicode' -__version__ = '1.1.6' +__version__ = '1.1.7' default_app_config = 'uuslug.apps.AppConfig' diff --git a/uuslug/tests/tests.py b/uuslug/tests/tests.py index 2375854..e203f5e 100644 --- a/uuslug/tests/tests.py +++ b/uuslug/tests/tests.py @@ -5,7 +5,7 @@ from django.test import TestCase # http://pypi.python.org/pypi/django-tools/ # from django_tools.unittest_utils.print_sql import PrintQueries -from uuslug import slugify +from uuslug import slugify, uuslug from uuslug.models import (CoolSlug, AnotherSlug, TruncatedSlug, SmartTruncatedSlug, SmartTruncatedExactWordBoundrySlug, CoolSlugDifferentSeparator, TruncatedSlugDifferentSeparator, @@ -265,3 +265,8 @@ class SlugMaxLengthTestCase(TestCase): # 10 is field max_length, 20 is uuslug function max_length obj = AutoTruncatedSlug.objects.create(name=name) self.assertEqual(obj.slug, "jaja-lol-1") + + +class ModelInstanceExeptionTestCase(TestCase): + def test_uuslug_checks_for_model_instance(self): + self.assertRaises(Exception, uuslug, 'test_slug', CoolSlug) diff --git a/uuslug/uuslug.py b/uuslug/uuslug.py index d061f82..8b331ae 100644 --- a/uuslug/uuslug.py +++ b/uuslug/uuslug.py @@ -1,3 +1,4 @@ +from django.db.models.base import ModelBase from slugify import slugify as pyslugify from django.utils import six if six.PY3: @@ -24,7 +25,7 @@ def uuslug(s, instance, entities=True, decimal=True, hexadecimal=True, """ This method tries a little harder than django's django.template.defaultfilters.slugify. """ - if hasattr(instance, 'objects'): + if isinstance(instance, ModelBase): raise Exception("Error: you must pass an instance to uuslug, not a model.") queryset = instance.__class__.objects.all()