Skip to content

Commit 4e7d909

Browse files
authored
[#826] switch to source layout (#827)
* move to src layout * fix coverage * PR feedback
1 parent f570794 commit 4e7d909

16 files changed

+35
-17
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ repos:
1515
rev: v1.0.1
1616
hooks:
1717
- id: seed-isort-config
18+
args: [--application-directories, src]
1819
- repo: https://github.com/pre-commit/mirrors-isort
1920
rev: v4.3.4
2021
hooks:

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def main():
4343
platforms=["unix", "linux", "osx", "cygwin", "win32"],
4444
author="holger krekel",
4545
author_email="[email protected]",
46-
packages=["tox"],
46+
packages=setuptools.find_packages("src"),
47+
package_dir={"": "src"},
4748
entry_points={
4849
"console_scripts": ["tox=tox:cmdline", "tox-quickstart=tox._quickstart:main"]
4950
},
@@ -59,7 +60,6 @@ def main():
5960
"pytest-xdist",
6061
],
6162
"docs": ["sphinx >= 1.6.3, < 2", "towncrier >= 17.8.0"],
62-
"lint": ["pre-commit == 1.8.2"],
6363
"publish": ["devpi", "twine"],
6464
},
6565
classifiers=[
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tox.ini

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,61 @@ skip_missing_interpreters = true
1212

1313
[testenv]
1414
description = run the tests with pytest under {basepython}
15-
setenv = COVERAGE_FILE={toxworkdir}/.coverage.{envname}
15+
setenv = PIP_DISABLE_VERSION_CHECK = 1
16+
COVERAGE_FILE = {toxworkdir}/.coverage.{envname}
1617
passenv = http_proxy https_proxy no_proxy SSL_CERT_FILE TOXENV CI TRAVIS TRAVIS_* APPVEYOR APPVEYOR_* CODECOV_*
18+
deps =
1719
extras = testing
18-
commands = pytest {posargs:--cov-config="{toxinidir}/tox.ini" --cov="{envsitepackagesdir}/tox" --timeout=180 tests}
20+
changedir = {toxinidir}/tests
21+
commands = pytest {posargs:--cov="{envsitepackagesdir}/tox" --cov-config="{toxinidir}/tox.ini" --timeout=180 .}
1922

2023
[testenv:docs]
2124
description = invoke sphinx-build to build the HTML docs and check that all links are valid
2225
whitelist_externals = sphinx-build
2326
basepython = python3.6
2427
extras = docs
28+
changedir = {toxinidir}
2529
commands = sphinx-build -d "{toxworkdir}/docs_doctree" doc "{toxworkdir}/docs_out" --color -W -bhtml
2630

2731

2832
[testenv:fix-lint]
33+
description = format the code base to adhere to our styles, and complain about what we cannot do automatically
2934
basepython = python3.6
3035
passenv = {[testenv]passenv}
3136
HOMEPATH
3237
# without PROGRAMDATA cloning using git for Windows will fail with an
3338
# `error setting certificate verify locations` error
3439
PROGRAMDATA
3540
extras = lint
36-
description = run static analysis and style check using flake8
41+
deps = pre-commit == 1.10.1
42+
skip_install = True
43+
changedir = {toxinidir}
3744
commands = pre-commit run --all-files --show-diff-on-failure
3845
python -c 'print("hint: run {envdir}/bin/pre-commit install to add checks as pre-commit hook")'
3946

4047

4148
[testenv:coverage]
42-
description = combine coverage data and create reports
43-
deps = coverage
49+
description = [run locally after tests]: combine coverage data and create report;
50+
generates a diff coverage against origin/master (can be changed by setting DIFF_AGAINST env var)
51+
deps = {[testenv]deps}
52+
coverage >= 4.4.1, < 5
53+
diff_cover
4454
skip_install = True
45-
changedir = {toxworkdir}
46-
setenv = COVERAGE_FILE=.coverage
55+
passenv = {[testenv]passenv}
56+
DIFF_AGAINST
57+
setenv = COVERAGE_FILE={toxworkdir}/.coverage
58+
changedir = {toxinidir}
4759
commands = coverage erase
4860
coverage combine
49-
coverage report --rcfile="{toxinidir}/tox.ini"
50-
coverage xml
61+
coverage report -m
62+
coverage xml -o {toxworkdir}/coverage.xml
63+
diff-cover --compare-branch {env:DIFF_AGAINST:origin/master} {toxworkdir}/coverage.xml
5164

5265
[testenv:codecov]
5366
description = [only run on CI]: upload coverage data to codecov (depends on coverage running first)
5467
deps = codecov
5568
skip_install = True
69+
changedir = {toxinidir}
5670
commands = codecov --file "{toxworkdir}/coverage.xml"
5771

5872
[testenv:exit_code]
@@ -61,13 +75,15 @@ commands = codecov --file "{toxworkdir}/coverage.xml"
6175
basepython = python3.6
6276
description = commands with several exit codes
6377
skip_install = True
78+
changedir = {toxinidir}
6479
commands = python3.6 -c "import sys; sys.exit(139)"
6580

6681
[testenv:pra]
6782
platform = linux
6883
passenv = *
6984
description = "personal release assistant" - see HOWTORELEASE.rst
7085
extras = publish, docs
86+
changedir = {toxinidir}
7187
commands = sphinx-build -d "{toxworkdir}/docs_doctree" doc "{toxworkdir}/docs_out" --color -W -blinkcheck
7288
"{toxinidir}/tasks/pra.sh" {posargs}
7389

@@ -81,6 +97,7 @@ extras = testing, docs
8197
# required to make looponfail reload on every source code change
8298
usedevelop = True
8399
basepython = python3.6
100+
changedir = {toxinidir}
84101
commands = python -m pip list --format=columns
85102
python -c 'import sys; print(sys.executable)'
86103

@@ -90,21 +107,21 @@ max-line-length = 99
90107
ignore = E203, W503
91108

92109
[coverage:run]
93-
omit = tox/__main__.py
110+
branch = true
94111

95112
[coverage:report]
96113
skip_covered = True
97114
show_missing = True
98115
exclude_lines = if __name__ == ["']__main__["']:
99116
100117
[coverage:paths]
101-
source = tox
102-
{toxworkdir}/*/lib/python*/site-packages/tox
103-
{toxworkdir}/*/Lib/site-packages/tox
104-
{toxworkdir}/pypy*/site-packages/tox
118+
source = src/tox
119+
.tox/*/lib/python*/site-packages/tox
120+
.tox/*/Lib/site-packages/tox
121+
.tox/pypy*/site-packages/tox
105122
106123
[pytest]
107-
addopts = -rsxX -vvv --showlocals
124+
addopts = -rsxX --showlocals
108125
rsyncdirs = tests tox
109126
looponfailroots = tox tests
110127
norecursedirs = .hg .tox

0 commit comments

Comments
 (0)