From 469989b16d303f7353e2aa123deef22d9c5bf602 Mon Sep 17 00:00:00 2001 From: Scott Searcy Date: Thu, 15 Nov 2018 08:28:15 -0800 Subject: [PATCH] Moved `dotenv` package into `src` directory so that tests run against installed version. Added tox to run test suite against multiple versions of Python (with coverage) and run flake8. Updated Travis CI to use tox as well. Updated documentation about running tests. --- .coveragerc | 15 ++++++--- .gitignore | 1 + .travis.yml | 49 +++++++++++++++++++++--------- MANIFEST.in | 11 +++++-- README.md | 6 ++++ requirements.txt | 1 + setup.cfg | 3 +- setup.py | 3 +- {dotenv => src/dotenv}/__init__.py | 0 {dotenv => src/dotenv}/cli.py | 0 {dotenv => src/dotenv}/compat.py | 0 {dotenv => src/dotenv}/ipython.py | 0 {dotenv => src/dotenv}/main.py | 0 {dotenv => src/dotenv}/version.py | 0 tox.ini | 37 ++++++++++++++++++++++ 15 files changed, 101 insertions(+), 25 deletions(-) rename {dotenv => src/dotenv}/__init__.py (100%) rename {dotenv => src/dotenv}/cli.py (100%) rename {dotenv => src/dotenv}/compat.py (100%) rename {dotenv => src/dotenv}/ipython.py (100%) rename {dotenv => src/dotenv}/main.py (100%) rename {dotenv => src/dotenv}/version.py (100%) create mode 100644 tox.ini diff --git a/.coveragerc b/.coveragerc index dedbcd87..18c6ca7f 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,6 +1,11 @@ [run] -source = dotenv/ -omit = - tests/* - venv/* - *conftest* +source = dotenv + +[paths] +source = + src/dotenv + .tox/*/lib/python*/site-packages/dotenv + .tox/pypy*/site-packages/dotenv + +[report] +show_missing = True diff --git a/.gitignore b/.gitignore index 89c02d5e..1f967f27 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ htmlcov/ .cache/ .idea .pytest_cache/ +.tox/ diff --git a/.travis.yml b/.travis.yml index 2353afd2..29ff965f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,26 +1,45 @@ language: python +cache: pip sudo: false -python: - - '2.7' - - '3.4' - - '3.5' - - '3.6' - - pypy -# Enable 3.7 without globally enabling sudo and dist: xenial for other build jobs +dist: xenial + matrix: include: - - python: 3.7 - dist: xenial - sudo: true + - python: "3.6" + env: TOXENV=lint + - python: "3.6" + env: TOXENV=manifest + + - python: "2.7" + env: TOXENV=py27 + - python: "3.4" + env: TOXENV=py34 + - python: "3.5" + env: TOXENV=py35 + - python: "3.6" + env: TOXENV=py36 + - python: "3.7" + env: TOXENV=py37 + - python: "pypy" + env: TOXENV=pypy + dist: trusty + - python: "pypy3" + env: TOXENV=pypy3 + dist: trusty + install: - - pip install python-coveralls - - pip install -q -r requirements.txt - - pip install --editable . + - pip install tox + script: - - flake8 . - - pytest -v --tb=native --cov + - tox + +before_install: + - pip install python-coveralls + after_success: + - tox -e coverage-report - coveralls + deploy: provider: pypi user: theskumar diff --git a/MANIFEST.in b/MANIFEST.in index a3080772..5cfb2e95 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,10 @@ -include LICENSE -include README.rst +include LICENSE *.md *.yml + +include tox.ini +recursive-include tests *.py + +include .bumpversion.cfg +include .coveragerc +include .editorconfig +include Makefile include requirements.txt diff --git a/README.md b/README.md index 1d558afd..2d3917da 100644 --- a/README.md +++ b/README.md @@ -282,9 +282,15 @@ people](https://github.com/theskumar/python-dotenv/graphs/contributors). Executing the tests: + $ pip install -r requirements.txt + $ pip install -e . $ flake8 $ pytest +or with [tox](https://pypi.org/project/tox/) installed: + + $ tox + Changelog ========= diff --git a/requirements.txt b/requirements.txt index 84b8661d..aee51b3c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,5 @@ pypandoc pytest-cov pytest>=3.9 sh>=1.09 +tox wheel diff --git a/setup.cfg b/setup.cfg index a97aff08..7f784591 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,5 +9,4 @@ exclude = .tox,.git,docs,venv,.venv description-file = README.rst [tool:pytest] -norecursedirs = .svn _build tmp* dist venv .git .venv venv -flake8-max-line-length = 120 +testpaths = tests diff --git a/setup.py b/setup.py index b7c54cc1..08b178e8 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ long_description = f.read() meta = {} -with open('./dotenv/version.py') as f: +with open('./src/dotenv/version.py') as f: exec(f.read(), meta) setup( @@ -28,6 +28,7 @@ keywords=['environment variables', 'deployments', 'settings', 'env', 'dotenv', 'configurations', 'python'], packages=['dotenv'], + package_dir={'': 'src'}, extras_require={ 'cli': ['click>=5.0', ], }, diff --git a/dotenv/__init__.py b/src/dotenv/__init__.py similarity index 100% rename from dotenv/__init__.py rename to src/dotenv/__init__.py diff --git a/dotenv/cli.py b/src/dotenv/cli.py similarity index 100% rename from dotenv/cli.py rename to src/dotenv/cli.py diff --git a/dotenv/compat.py b/src/dotenv/compat.py similarity index 100% rename from dotenv/compat.py rename to src/dotenv/compat.py diff --git a/dotenv/ipython.py b/src/dotenv/ipython.py similarity index 100% rename from dotenv/ipython.py rename to src/dotenv/ipython.py diff --git a/dotenv/main.py b/src/dotenv/main.py similarity index 100% rename from dotenv/main.py rename to src/dotenv/main.py diff --git a/dotenv/version.py b/src/dotenv/version.py similarity index 100% rename from dotenv/version.py rename to src/dotenv/version.py diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..e174c622 --- /dev/null +++ b/tox.ini @@ -0,0 +1,37 @@ +[tox] +envlist = lint,py{27,34,35,36,37},pypy,pypy3,manifest,coverage-report + +[testenv] +deps = + pytest + coverage + sh + click + py{27,py}: ipython<6.0.0 + py34: ipython<7.0.0 + py{35,36,37,py3}: ipython +commands = coverage run --parallel -m pytest {posargs} + +[testenv:lint] +skip_install = true +deps = + flake8 +commands = + flake8 src tests + +[testenv:manifest] +deps = check-manifest +skip_install = true +commands = check-manifest + +[testenv:coverage-clean] +deps = coverage +skip_install = true +commands = coverage erase + +[testenv:coverage-report] +deps = coverage +skip_install = true +commands = + coverage combine + coverage report