Skip to content

Commit 80f6952

Browse files
authored
use tox instead of 'setup.py test' (#833)
* use tox instead of setup.py test * fix error in .appveyor.yml * pass TEST_SOCKETCAN environment variable for travis
1 parent 05f500e commit 80f6952

File tree

7 files changed

+93
-77
lines changed

7 files changed

+93
-77
lines changed

.appveyor.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@ install:
1414
# Prepend Python installation and scripts (e.g. pytest) to PATH
1515
- set PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%
1616

17-
# We need to install the python-can library itself including the dependencies
18-
- "python -m pip install .[test,neovi]"
17+
# Install tox
18+
- "pip install tox"
1919

2020
build: off
2121

2222
test_script:
2323
# run tests
24-
- "pytest"
25-
26-
# uplad coverage reports
27-
- "codecov -X gcov"
24+
- "tox -e appveyor"

.travis.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,14 @@ env:
2121

2222
install:
2323
- if [[ "$TEST_SOCKETCAN" ]]; then sudo bash test/open_vcan.sh ; fi
24-
- travis_retry pip install .[test]
24+
- python setup.py install
2525

2626
script:
2727
- |
28+
# install tox
29+
pip install tox
2830
# Run the tests
29-
python setup.py test
30-
# preserve the error code
31-
RETURN_CODE=$?
32-
# Upload the coverage to codecov.io
33-
codecov -X gcov
34-
# set error code
35-
(exit $RETURN_CODE);
36-
31+
tox -e travis
3732
3833
jobs:
3934
allow_failures:

doc/development.rst

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,30 @@ Building & Installing
2222

2323
The following assumes that the commands are executed from the root of the repository:
2424

25-
- The project can be built and installed with ``python setup.py build`` and
26-
``python setup.py install``.
27-
- The unit tests can be run with ``python setup.py test``. The tests can be run with ``python2``,
28-
``python3``, ``pypy`` or ``pypy3`` to test with other python versions, if they are installed.
29-
Maybe, you need to execute ``pip3 install python-can[test]`` (or only ``pip`` for Python 2),
30-
if some dependencies are missing.
31-
- The docs can be built with ``sphinx-build doc/ doc/_build``. Appending ``-n`` to the command
32-
makes Sphinx complain about more subtle problems.
25+
The project can be built with::
26+
27+
pip install wheel
28+
python setup.py sdist bdist_wheel
29+
30+
The project can be installed in editable mode with::
31+
32+
pip install -e .
33+
34+
The unit tests can be run with::
35+
36+
pip install tox
37+
tox
38+
39+
The documentation can be built with::
40+
41+
pip install -r doc/doc-requirements.txt
42+
python -m sphinx -an doc build
43+
44+
The linters can be run with::
45+
46+
pip install -r requirements-lint.txt
47+
pylint --rcfile=.pylintrc-wip can/**.py
48+
black --check --verbose can
3349

3450

3551
Creating a new interface/backend
@@ -81,7 +97,7 @@ Creating a new Release
8197
- Update `CONTRIBUTORS.txt` with any new contributors.
8298
- For larger changes update ``doc/history.rst``.
8399
- Sanity check that documentation has stayed inline with code.
84-
- Create a temporary virtual environment. Run ``python setup.py install`` and ``python setup.py test``.
100+
- Create a temporary virtual environment. Run ``python setup.py install`` and ``tox``.
85101
- Create and upload the distribution: ``python setup.py sdist bdist_wheel``.
86102
- Sign the packages with gpg ``gpg --detach-sign -a dist/python_can-X.Y.Z-py3-none-any.whl``.
87103
- Upload with twine ``twine upload dist/python-can-X.Y.Z*``.

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build-system]
2+
requires = [
3+
"setuptools >= 40.8",
4+
"wheel",
5+
]
6+
build-backend = "setuptools.build_meta"

setup.cfg

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,2 @@
1-
[aliases]
2-
test=pytest
3-
41
[metadata]
52
license_file = LICENSE.txt
6-
7-
[tool:pytest]
8-
addopts = -v --timeout=300 --cov=can --cov-config=setup.cfg
9-
10-
[coverage:run]
11-
# we could also use branch coverage
12-
branch = False
13-
# already specified by call to pytest using --cov=can
14-
#source = can
15-
16-
[coverage:report]
17-
# two digits after decimal point
18-
precision = 3
19-
show_missing = True
20-
exclude_lines =
21-
# Have to re-enable the standard pragma, see https://coverage.readthedocs.io/en/coverage-4.5.1a/config.html#syntax
22-
pragma: no cover
23-
24-
# Don't complain if non-runnable code isn't run:
25-
if __name__ == .__main__.:

setup.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from os.path import isfile, join
1313
import re
1414
import logging
15-
import sys
1615
from setuptools import setup, find_packages
1716

1817
logging.basicConfig(level=logging.WARNING)
@@ -29,30 +28,9 @@
2928
extras_require = {
3029
"seeedstudio": ["pyserial>=3.0"],
3130
"serial": ["pyserial~=3.0"],
32-
"neovi": ["python-ics>=2.12", "filelock"],
31+
"neovi": ["python-ics>=2.12"],
3332
}
3433

35-
tests_require = [
36-
"pytest~=5.3",
37-
"pytest-timeout~=1.3",
38-
"pytest-cov~=2.8",
39-
# coveragepy==5.0 fails with `Safety level may not be changed inside a transaction`
40-
# on python 3.6 on MACOS
41-
"coverage<5",
42-
"codecov~=2.0",
43-
"hypothesis~=4.56",
44-
] + extras_require["serial"]
45-
46-
extras_require["test"] = tests_require
47-
48-
# Check for 'pytest-runner' only if setup.py was invoked with 'test'.
49-
# This optimizes setup.py for cases when pytest-runner is not needed,
50-
# using the approach that is suggested upstream.
51-
#
52-
# See https://pypi.org/project/pytest-runner/#conditional-requirement
53-
needs_pytest = {"pytest", "test", "ptr"}.intersection(sys.argv)
54-
pytest_runner = ["pytest-runner"] if needs_pytest else []
55-
5634
setup(
5735
# Description
5836
name="python-can",
@@ -110,7 +88,5 @@
11088
"mypy_extensions >= 0.4.0, < 0.5.0",
11189
'pywin32;platform_system=="Windows"',
11290
],
113-
setup_requires=pytest_runner,
11491
extras_require=extras_require,
115-
tests_require=tests_require,
11692
)

tox.ini

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,60 @@
11
[tox]
2-
envlist = py36, py37
32

43
[testenv]
4+
deps =
5+
pytest~=5.3
6+
pytest-timeout~=1.3
7+
pytest-cov~=2.8
8+
coverage<5
9+
codecov~=2.0
10+
hypothesis~=4.56
11+
pyserial~=3.0
12+
513
commands =
6-
pip install .[test]
714
pytest
8-
passenv = CI
15+
916
recreate = True
10-
usedevelop = True
11-
sitepackages=False
17+
18+
[testenv:travis]
19+
passenv =
20+
CI
21+
TRAVIS
22+
TRAVIS_*
23+
TEST_SOCKETCAN
24+
25+
commands_post =
26+
codecov -X gcov
27+
28+
[testenv:appveyor]
29+
passenv =
30+
CI
31+
APPVEYOR
32+
APPVEYOR_*
33+
34+
extras = neovi
35+
36+
commands_post =
37+
codecov -X gcov
38+
39+
[pytest]
40+
testpaths = test
41+
addopts = -v --timeout=300 --cov=can --cov-append --cov-report=term
42+
43+
44+
[coverage:run]
45+
# we could also use branch coverage
46+
branch = False
47+
48+
[coverage:report]
49+
# two digits after decimal point
50+
precision = 3
51+
show_missing = True
52+
exclude_lines =
53+
# Have to re-enable the standard pragma, see https://coverage.readthedocs.io/en/coverage-4.5.1a/config.html#syntax
54+
pragma: no cover
55+
56+
# Don't complain if non-runnable code isn't run:
57+
if __name__ == .__main__.:
58+
59+
# Don't complain if tests don't hit defensive assertion code:
60+
raise NotImplementedError

0 commit comments

Comments
 (0)