From ae9ccbd5178f359a4e07a7491c629b10a3843133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Barrois?= Date: Thu, 1 Sep 2016 13:36:37 +0200 Subject: Rearrange test suite. * Use tox * Add a full linting step --- .flake8 | 4 ++++ .gitignore | 2 +- .travis.yml | 37 ++++++++++++++++++++++++++----------- MANIFEST.in | 20 +++++++++++--------- Makefile | 39 ++++++++++++++++++--------------------- dev_requirements.txt | 2 -- requirements_dev.txt | 12 ++++++++++++ requirements_test.txt | 3 +++ tox.ini | 24 ++++++++++++++++++++++++ 9 files changed, 99 insertions(+), 44 deletions(-) create mode 100644 .flake8 delete mode 100644 dev_requirements.txt create mode 100644 requirements_dev.txt create mode 100644 requirements_test.txt create mode 100644 tox.ini diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..eceea15 --- /dev/null +++ b/.flake8 @@ -0,0 +1,4 @@ +[flake8] +# Ignore "and" at start of line. +ignore = W503 +max-line-length = 120 diff --git a/.gitignore b/.gitignore index 60b6b01..b4d25fc 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,8 @@ # Build-related files docs/_build/ -auto_dev_requirements*.txt .coverage +.tox *.egg-info *.egg build/ diff --git a/.travis.yml b/.travis.yml index 6574bf9..02d3739 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,34 @@ +sudo: false language: python -python: - - "2.7" - - "3.4" - - "3.5" -env: - - DJANGO_VERSION=1.8 - - DJANGO_VERSION=1.9 - - DJANGO_VERSION=1.10 - script: - - python setup.py test + - tox install: - - make install-deps + - pip install tox + +matrix: + include: + - python: "2.7" + env: TOXENV=py27-django17 + env: TOXENV=py27-django18 + env: TOXENV=py27-django19 + env: TOXENV=py27-django110 + - python: "3.4" + env: TOXENV=py34-django110 + - python: "3.5" + env: TOXENV=py35-django17 + env: TOXENV=py35-django18 + env: TOXENV=py35-django19 + env: TOXENV=py35-django110 + + # Pypy + - python: "pypy" + env: TOXENV=py27-django110 + + # Linting + - python: "3.5" + env: TOXENV=lint notifications: email: false diff --git a/MANIFEST.in b/MANIFEST.in index c35e2a3..7b49f89 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,9 +1,11 @@ -include CREDITS -include ChangeLog -include LICENSE -include README.rst -include docs/Makefile -recursive-include docs *.py *.rst -include docs/_static/.keep_dir -prune docs/_build -recursive-include tests *.py +include CREDITS ChangeLog LICENSE README.rst +include requirements*.txt + +graft semantic_version + +prune docs +prune tests + +global-exclude .py[cod] __pycache__ + +exclude Makefile tox.ini .flake8 diff --git a/Makefile b/Makefile index 52b8e8b..626f21c 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,7 @@ DOC_DIR=docs # Use current python binary instead of system default. COVERAGE = python $(shell which coverage) - -# Dependencies -DJANGO_VERSION ?= 1.10 -PYTHON_VERSION := $(shell python --version) -NEXT_DJANGO_VERSION=$(shell python -c "v='$(DJANGO_VERSION)'; parts=v.split('.'); parts[-1]=str(int(parts[-1])+1); print('.'.join(parts))") - +FLAKE8 = flake8 all: default @@ -17,30 +12,32 @@ all: default default: -install-deps: auto_dev_requirements_django_$(DJANGO_VERSION).txt - pip install --upgrade pip setuptools - pip install --upgrade -r $< - pip freeze - -auto_dev_requirements_%.txt: dev_requirements.txt requirements.txt - grep --no-filename "^[^#-]" $^ | grep -v "^Django" > $@ - echo "Django>=$(DJANGO_VERSION),<$(NEXT_DJANGO_VERSION)" >> $@ - clean: find . -type f -name '*.pyc' -delete find . -type f -path '*/__pycache__/*' -delete find . -type d -empty -delete - @rm -f auto_dev_requirements_* @rm -rf tmp_test/ -test: install-deps +install-deps: + pip install --upgrade pip setuptools + pip install --upgrade -r requirements_dev.txt + pip freeze + +testall: + tox + + +test: python -W default setup.py test -pylint: - pylint --rcfile=.pylintrc --report=no $(PACKAGE)/ +# Note: we run the linter in two runs, because our __init__.py files has specific warnings we want to exclude +lint: + check-manifest + $(FLAKE8) --config .flake8 --exclude $(PACKAGE)/__init__.py $(PACKAGE) + $(FLAKE8) --config .flake8 --ignore F401 $(PACKAGE)/__init__.py -coverage: install-deps +coverage: $(COVERAGE) erase $(COVERAGE) run "--include=$(PACKAGE)/*.py,$(TESTS_DIR)/*.py" --branch setup.py test $(COVERAGE) report "--include=$(PACKAGE)/*.py,$(TESTS_DIR)/*.py" @@ -53,4 +50,4 @@ doc: $(MAKE) -C $(DOC_DIR) html -.PHONY: all default clean coverage doc install-deps pylint test +.PHONY: all default clean coverage doc install-deps lint test diff --git a/dev_requirements.txt b/dev_requirements.txt deleted file mode 100644 index 75e67d6..0000000 --- a/dev_requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -Django -coverage diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..d7feb34 --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,12 @@ +# Requirements for local development +-e . +-r requirements_test.txt + +Django + +coverage +wheel +tox + +Sphinx +sphinx_rtd_theme diff --git a/requirements_test.txt b/requirements_test.txt new file mode 100644 index 0000000..35012df --- /dev/null +++ b/requirements_test.txt @@ -0,0 +1,3 @@ +# Common requirements for running tests +check_manifest +flake8 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..cd28e4f --- /dev/null +++ b/tox.ini @@ -0,0 +1,24 @@ +[tox] +envlist = + py{27,34,35}-django{17,18,19,110} + lint + +toxworkdir = {env:TOX_WORKDIR:.tox} + +[testenv] +deps = + -rrequirements_test.txt + django17: Django>=1.7,<1.8 + django18: Django>=1.8,<1.9 + django19: Django>=1.9,<1.10 + django110: Django>=1.10,<1.11 + +whitelist_externals = make +commands = make test + +[testenv:lint] +deps = + -rrequirements_test.txt + +whitelist_externals = make +commands = make lint -- cgit v1.2.1