diff --git a/.travis.yml b/.travis.yml index a92777c..454beff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: python +install: pip install tox-travis +script: tox + python: - - 2.7 -install: pip install tox --use-mirrors -script: tox \ No newline at end of file + - "2.7" + - "3.7" diff --git a/README.rst b/README.rst index 1f74e86..0c6e36a 100644 --- a/README.rst +++ b/README.rst @@ -1,3 +1,6 @@ +.. image:: https://travis-ci.org/supervacuo/django-memcachedkeys.svg?branch=python3 + :target: https://travis-ci.org/supervacuo/django-memcachedkeys + ============================= django-memcachedkeys ============================= diff --git a/memcachedkeys/__init__.py b/memcachedkeys/__init__.py index aff3661..7615a6e 100644 --- a/memcachedkeys/__init__.py +++ b/memcachedkeys/__init__.py @@ -1,9 +1,11 @@ +from __future__ import unicode_literals + from memcachedkeys.pkgmeta import * import re from hashlib import md5 -bad_key_chars = re.compile(ur'[\u0000-\u001f\s]+') +bad_key_chars = re.compile(r'[\u0000-\u001f\s]+') MAX_LENGTH = 250 @@ -17,7 +19,7 @@ def make_key(key, key_prefix, version): full_key = ':'.join([key_prefix, version_str, clean_key]) if clean_key != key or len(full_key) > MAX_LENGTH: - hashed_key = md5(key).hexdigest() + hashed_key = md5(key.encode('utf-8')).hexdigest() abbrev_keylen = MAX_LENGTH - len(hashed_key) - len('::[]') - len(key_prefix) - len(version_str) new_key = '%s[%s]' % (clean_key[:abbrev_keylen], hashed_key) full_key = ':'.join([key_prefix, version_str, new_key]) diff --git a/memcachedkeys/pkgmeta.py b/memcachedkeys/pkgmeta.py index f56911d..4e3d0f2 100644 --- a/memcachedkeys/pkgmeta.py +++ b/memcachedkeys/pkgmeta.py @@ -5,4 +5,4 @@ ) globals().update(pkgmeta) -__all__ = pkgmeta.keys() \ No newline at end of file +__all__ = list(pkgmeta.keys()) \ No newline at end of file diff --git a/setup.py b/setup.py index 8640c81..81411b1 100755 --- a/setup.py +++ b/setup.py @@ -8,23 +8,10 @@ pkgmeta = {} -execfile(os.path.join(os.path.dirname(__file__), - 'memcachedkeys', 'pkgmeta.py'), pkgmeta) - - -class PyTest(TestCommand): - def finalize_options(self): - TestCommand.finalize_options(self) - self.test_args = ['tests', '-s'] - self.test_suite = True - - def run_tests(self): - import pytest - # Make sure this package's tests module gets priority. - sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) - errno = pytest.main(self.test_args) - sys.exit(errno) - +pkgmeta_path = os.path.join(os.path.dirname(__file__), 'memcachedkeys', 'pkgmeta.py') +with open(pkgmeta_path) as f: + code = compile(f.read(), pkgmeta_path, 'exec') + exec(code, pkgmeta) class LintCommand(Command): """ @@ -65,11 +52,8 @@ def distribution_files(self): setup_requires=[ 'flake8', ], - tests_require=[ - 'pytest-django', - ], install_requires=[ - 'Django>=1.2', + 'Django>=1.11', ], zip_safe=False, keywords='django-memcachedkeys', @@ -86,7 +70,6 @@ def distribution_files(self): 'Programming Language :: Python :: 3.3', ], cmdclass={ - 'test': PyTest, 'lint': LintCommand, }, ) diff --git a/tox.ini b/tox.ini index f7c7366..c59d659 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,13 @@ [tox] -envlist = py27, py26 +envlist = + py37-django{200,202}, + {py27,py37}-django{110,111}, [testenv] -commands = python setup.py test +commands = pytest tests -s +deps = + pytest-django + django110: Django==1.10.8 + django111: Django==1.11.26 + django200: Django==2.0.13 + django202: Django==2.2.7