From b401c3d2eac2aa9b73815034b44af75f65e6d7bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Barrois?= Date: Wed, 6 Apr 2016 23:51:15 +0200 Subject: Refactor test setup/commands, enable tox. Closes #273. --- MANIFEST.in | 2 ++ Makefile | 42 ++++++++++++------------------------------ dev_requirements.txt | 13 ------------- requirements_dev.txt | 14 ++++++++++++++ requirements_test.txt | 2 ++ tox.ini | 35 +++++++++++++++++++++++++++++++++++ 6 files changed, 65 insertions(+), 43 deletions(-) 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/MANIFEST.in b/MANIFEST.in index 3dfc1be..22f4a5c 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,6 @@ include README.rst +include requirements*.txt + include docs/Makefile recursive-include docs *.py *.rst include docs/_static/.keep_dir diff --git a/Makefile b/Makefile index da8ac88..de0243f 100644 --- a/Makefile +++ b/Makefile @@ -6,55 +6,37 @@ EXAMPLES_DIR=examples # Use current python binary instead of system default. COVERAGE = python $(shell which coverage) -# Dependencies -DJANGO ?= 1.9 -NEXT_DJANGO = $(shell python -c "v='$(DJANGO)'; parts=v.split('.'); parts[-1]=str(int(parts[-1])+1); print('.'.join(parts))") - -ALCHEMY ?= 1.0 -NEXT_ALCHEMY = $(shell python -c "v='$(ALCHEMY)'; parts=v.split('.'); parts[-1]=str(int(parts[-1])+1); print('.'.join(parts))") - -MONGOENGINE ?= 0.10 -NEXT_MONGOENGINE = $(shell python -c "v='$(MONGOENGINE)'; parts=v.split('.'); parts[-1]=str(int(parts[-1])+1); print('.'.join(parts))") - -REQ_FILE = auto_dev_requirements_django$(DJANGO)_alchemy$(ALCHEMY)_mongoengine$(MONGOENGINE).txt -EXAMPLES_REQ_FILES = $(shell find $(EXAMPLES_DIR) -name requirements.txt) - all: default default: -install-deps: $(REQ_FILE) - pip install --upgrade pip setuptools - pip install --upgrade -r $< - pip freeze - -$(REQ_FILE): dev_requirements.txt requirements.txt $(EXAMPLES_REQ_FILES) - grep --no-filename "^[^#-]" $^ | egrep -v "^(Django|SQLAlchemy|mongoengine)" > $@ - echo "Django>=$(DJANGO),<$(NEXT_DJANGO)" >> $@ - echo "SQLAlchemy>=$(ALCHEMY),<$(NEXT_ALCHEMY)" >> $@ - echo "mongoengine>=$(MONGOENGINE),<$(NEXT_MONGOENGINE)" >> $@ - - 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 example-test - python -W default setup.py test +install-deps: + pip install --upgrade pip setuptools + pip install --upgrade -r requirements_dev.txt + pip freeze + +testall: + tox + +test: + python -Wdefault -m unittest $(TESTS_DIR) example-test: $(MAKE) -C $(EXAMPLES_DIR) test -pylint: +lint: pylint --rcfile=.pylintrc --report=no $(PACKAGE)/ -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" diff --git a/dev_requirements.txt b/dev_requirements.txt deleted file mode 100644 index c78aa9d..0000000 --- a/dev_requirements.txt +++ /dev/null @@ -1,13 +0,0 @@ --r requirements.txt --r examples/requirements.txt - -coverage -Django -Pillow -SQLAlchemy -mongoengine -mock -wheel - -Sphinx -sphinx_rtd_theme diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..a7706c6 --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,14 @@ +-e . +-r requirements_test.txt +-r examples/requirements.txt + +coverage +Django +Pillow +SQLAlchemy +mongoengine +wheel +tox + +Sphinx +sphinx_rtd_theme diff --git a/requirements_test.txt b/requirements_test.txt new file mode 100644 index 0000000..e37a8fe --- /dev/null +++ b/requirements_test.txt @@ -0,0 +1,2 @@ +mock +pylint diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..bbcf538 --- /dev/null +++ b/tox.ini @@ -0,0 +1,35 @@ +[tox] +envlist = + py{27,34}-django{17,18,19} + py{27,34}-alchemy10 + py{27,34}-mongoengine010 + examples + 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 + django{17,18,19}: Pillow + alchemy10: SQLAlchemy>=1.0,<1.1 + mongoengine010: mongoengine>=0.10,<0.11 + +whitelist_externals = make +commands = make test + +[testenv:examples] +basepython = python3.4 +deps = + -rrequirements_test.txt + -rexamples/requirements.txt + +whitelist_externals = make +commands = make example-test + +[testenv:lint] +whitelist_externals = make +commands = make lint -- cgit v1.2.3