diff --git a/.travis.yml b/.travis.yml index 06890b7..ba94b8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,45 +1,39 @@ language: python python: + - "3.4" - "3.5" + - "3.6" env: - - TOX_ENV=py35-django18 - - TOX_ENV=py35-django19 - - TOX_ENV=py34-django18 - - TOX_ENV=py34-django19 - - TOX_ENV=py27-django18 - - TOX_ENV=py27-django19 - - TOX_ENV=lint - - TOX_ENV=coverage - - TOX_ENV=docs + - DJANGO=1.8 + - DJANGO=1.11 + - DJANGO=2.0 install: - - pip install -U tox + - pip install tox tox-travis script: - tox -jobs: - include: - - stage: deploy - env: TOX_ENV=py35-django19 - deploy: - provider: pypi - user: thorgate - password: - secure: > - gsOZAUv7GMDdQ5PVyi8+qpZSLZJ0bGs+iX8i7acIHFZU3jHpMm3NevMIuka8Xkd0cpnEW9xmAqGf6UyEW0pLa/dp5NWlggUIsRdFS0JH9aQ7c - A0cRbAPQo5ZjAaVqcHDjmKHAVjfRvHOvAcceRe/AODm/EBXx2pzxHb2YSOolFuSmK0OWjaAoJ0kK1DoWI2gltOoPC3NebdTJCmcdn1thmh1su - LanvkOn9v6363KrGz7t3y4h7qvmAYH0iM3xyarHPwodd1vChnvHdXEJoNFHzPuMcvI44nOlrf6phhFyyGyzsJQrwITwAROzLLRuKq1VbFS+nc - yj7vPa8CRh9J26ccA/W4tx0AqkwsFVxHdDIrbQ7apZ8TXIWDovv9nxRoN8e8fr+5u4umUbKLBgBKINfW2BA9LyqMCBj7YaNUwNAYxxMu8xBO4 - m6DUuCDZqXyMQVgZraJwrn0p1qmyacAcOJMbcNNlmwvo6+4kMgKVvsoFBAB9MOqH1y4UFgXsvvbx2sN46XDqmvagjtlyZMcHh6L5riRhhTl8r - YZLCmM62WKM05hjx03KDVHlNVSs4VWVCXVXkrIlDm8rHM0wy6pWUov9LREoazaDL11vAFbKBM0D3qOhDzZlD1xECa3lRWW1K3g1Pa5/DatozO - NyOCYve/jqlkfFKV3VEvgEBBBqF5g= - on: - tags: true - distributions: sdist bdist_wheel - repo: thorgate/tg-utils +deploy: + provider: pypi + user: thorgate + password: + secure: > + gsOZAUv7GMDdQ5PVyi8+qpZSLZJ0bGs+iX8i7acIHFZU3jHpMm3NevMIuka8Xkd0cpnEW9xmAqGf6UyEW0pLa/dp5NWlggUIsRdFS0JH9aQ7c + A0cRbAPQo5ZjAaVqcHDjmKHAVjfRvHOvAcceRe/AODm/EBXx2pzxHb2YSOolFuSmK0OWjaAoJ0kK1DoWI2gltOoPC3NebdTJCmcdn1thmh1su + LanvkOn9v6363KrGz7t3y4h7qvmAYH0iM3xyarHPwodd1vChnvHdXEJoNFHzPuMcvI44nOlrf6phhFyyGyzsJQrwITwAROzLLRuKq1VbFS+nc + yj7vPa8CRh9J26ccA/W4tx0AqkwsFVxHdDIrbQ7apZ8TXIWDovv9nxRoN8e8fr+5u4umUbKLBgBKINfW2BA9LyqMCBj7YaNUwNAYxxMu8xBO4 + m6DUuCDZqXyMQVgZraJwrn0p1qmyacAcOJMbcNNlmwvo6+4kMgKVvsoFBAB9MOqH1y4UFgXsvvbx2sN46XDqmvagjtlyZMcHh6L5riRhhTl8r + YZLCmM62WKM05hjx03KDVHlNVSs4VWVCXVXkrIlDm8rHM0wy6pWUov9LREoazaDL11vAFbKBM0D3qOhDzZlD1xECa3lRWW1K3g1Pa5/DatozO + NyOCYve/jqlkfFKV3VEvgEBBBqF5g= + distributions: sdist bdist_wheel + on: + repo: thorgate/tg-utils + tags: true + python: "3.6" + condition: "$DJANGO = 2.0" notifications: email: false diff --git a/HISTORY.rst b/HISTORY.rst index 9dcd7a1..bee8cb7 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,6 +2,14 @@ History ======= +0.3.0 (2018-03-12) +------------------ + +* Supported Django versions are now 1.8, 1.11, and 2.0. + `ClosableModel.created_by` and `closed_by` now have `on_delete=models.SET_NULL` attribute. +* Supported Python versions are now 3.4, 3.5, and 3.6. + + 0.2.0 (2016-01-27) ------------------ diff --git a/Makefile b/Makefile index 621bca9..a8ac439 100644 --- a/Makefile +++ b/Makefile @@ -51,14 +51,13 @@ lint: test: py.test +test-full: test lint coverage + test-all: tox coverage: - coverage run --source tg_utils setup.py test - coverage report -m - coverage html - $(BROWSER) htmlcov/index.html + py.test --cov-config .coveragerc --cov=tg_utils --cov-report html --cov-report term-missing docs: rm -f docs/tg_utils.rst diff --git a/docs/conf.py b/docs/conf.py index 55ec7e2..dab7303 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -60,7 +60,7 @@ # General information about the project. project = u'tg-utils' -copyright = u'2016, Thorgate' +copyright = u'2018, Thorgate' # The version info for the project you're documenting, acts as replacement # for |version| and |release|, also used in various other places throughout diff --git a/requirements_test.txt b/requirements_test.txt index 1ac0243..31e2e8f 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,4 +1,8 @@ pytest==2.8.5 +coverage==4.2 +coveralls==1.1 +pytest-cov==2.4.0 pytest-django==2.9.1 django_compressor==2.0 hashids==1.1.0 +flake8==2.5.1 diff --git a/setup.cfg b/setup.cfg index 65575e8..f78d492 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,3 +8,5 @@ tag = True [wheel] universal = 1 +[flake8] +max-line-length = 140 diff --git a/setup.py b/setup.py index 712f627..7795ca2 100755 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ history = history_file.read() requirements = [ - 'django>=1.8,<1.10', + 'django>=1.8,<2.1', ] setup( @@ -43,10 +43,9 @@ 'Intended Audience :: Developers', 'License :: OSI Approved :: ISC License (ISCL)', 'Natural Language :: English', - "Programming Language :: Python :: 2", - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', ], ) diff --git a/tests/django_settings.py b/tests/django_settings.py index 02b7127..47cc7fc 100644 --- a/tests/django_settings.py +++ b/tests/django_settings.py @@ -3,7 +3,7 @@ DEBUG = True -SECRET_KEY='hunter2' +SECRET_KEY = 'hunter2' SITE_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) diff --git a/tests/test_importing.py b/tests/test_importing.py index 1dd2522..9e2d3e2 100644 --- a/tests/test_importing.py +++ b/tests/test_importing.py @@ -1,3 +1,6 @@ +# flake8: noqa + + def test_imports(): """ Ensures all submodules are importable diff --git a/tg_utils/__init__.py b/tg_utils/__init__.py index 3b1e189..15a098e 100644 --- a/tg_utils/__init__.py +++ b/tg_utils/__init__.py @@ -2,4 +2,4 @@ __author__ = 'Thorgate' __email__ = 'code@thorgate.eu' -__version__ = '0.2.0' +__version__ = '0.3.0' diff --git a/tg_utils/models.py b/tg_utils/models.py index 002b1cc..9974236 100644 --- a/tg_utils/models.py +++ b/tg_utils/models.py @@ -12,10 +12,10 @@ class ClosableModel(models.Model): Also provides default manager that automatically filters queryset to only include active (non-closed) items plus a .close() function to mark objects as closed. """ - created_by = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='+', null=True, blank=True) + created_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, related_name='+', null=True, blank=True) created_at = models.DateTimeField(default=timezone.now) - closed_by = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='+', null=True, blank=True) + closed_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, related_name='+', null=True, blank=True) closed_at = models.DateTimeField(null=True, blank=True) all_objects = models.Manager() diff --git a/tg_utils/profiling.py b/tg_utils/profiling.py index b6b2b76..f92e57f 100644 --- a/tg_utils/profiling.py +++ b/tg_utils/profiling.py @@ -22,7 +22,7 @@ def profile_yappi(label): func_stats = yappi.get_func_stats() file_prefix = '/tmp/profile-yappi-%s-%s' % (label, timestamp.isoformat('T')) with open(file_prefix + '-summary.txt', 'w') as f: - func_stats.print_all(out=f, columns={0:("name",140), 1:("ncall", 8), 2:("tsub", 8), 3:("ttot", 8), 4:("tavg",8)}) + func_stats.print_all(out=f, columns={0: ("name", 140), 1: ("ncall", 8), 2: ("tsub", 8), 3: ("ttot", 8), 4: ("tavg", 8)}) func_stats.save(file_prefix + '.kgrind', 'CALLGRIND') yappi.stop() yappi.clear_stats() diff --git a/tox.ini b/tox.ini index 0b91d5e..b666a99 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,11 @@ [tox] -envlist = py{27,34,35}-django{18,19} +envlist = py{34,35,36}-django{18,111,20} + +[travis:env] +DJANGO = + 1.8: django18 + 1.11: django111 + 2.0: django20 [testenv] setenv = @@ -8,5 +14,9 @@ whitelist_externals = make commands = make test deps = django18: Django>=1.8,<1.9 - django19: Django>=1.9,<1.10 + django111: Django>=1.11,<1.12 + django20: Django>=2.0,<2.1 -r{toxinidir}/requirements_test.txt + +[testenv:py36-django20] +commands = make test-full