Skip to content

Commit 8feef8a

Browse files
altendkyebroecker
authored andcommittedSep 7, 2018
[WIP] Add pytest and tox (ebroecker#185)
* Add pytest and tox ebroecker#184 * Try again for both 3.4 and 3.7 on Travis * Add PyPy and PyPy3.5 on Travis * Trigger for AppVeyor * Try again on build version setting for AppVeyor * add missing get_version.py * Separate wheel build on AppVeyor * Print sys.version for each Tox env * Drop 32/64 on AppVeyor * fix * Add pypy/pypy3 for AppVeyor * Print sys.version for the AppVeyor virtualenv * Switch to 3.7/venv on AppVeyor * Allow pypy3 to fail on AppVeyor for now Could fork https://github.com/kirbyfan64/python.pypy * fix * fix * Trigger for AppVeyor * Attempt to add wheel job on Travis * Revert "Attempt to add wheel job on Travis" This reverts commit f308893. * Try again for a wheel job on Travis * Add coverage.py/codecov.io * Add back old tests on Travis * and old tests for 2.7 too * correct old tests for 3.7 * sdist as well * and collect sdist as well on AppVeyor * set envdir for dist tox target tox-dev/tox#696 * CI build dist first * kick ci
1 parent 2e5388c commit 8feef8a

12 files changed

+166
-6
lines changed
 

‎.coveragerc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[run]
2+
branch = True
3+
source =
4+
canmatrix
5+
6+
[report]
7+
show_missing = True

‎.travis.yml

+30-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
11
language: python
2-
python:
3-
- "2.7"
4-
- "3.5"
5-
# command to run tests
6-
script: source ./test.sh
2+
3+
matrix:
4+
include:
5+
- python: 3.7
6+
dist: xenial
7+
sudo: true
8+
env: TOXENV=dist
9+
- python: 2.7
10+
- python: pypy
11+
- python: 3.4
12+
- python: 3.5
13+
- python: pypy3.5
14+
- python: 3.6
15+
- python: 3.7
16+
dist: xenial
17+
sudo: true
18+
- python: 2.7
19+
env: TOXENV=old_tests
20+
- python: 3.7
21+
dist: xenial
22+
sudo: true
23+
env: TOXENV=old_tests
24+
25+
install:
26+
- pip install tox-travis
27+
- pip install -r requirements.tox.txt
28+
29+
script:
30+
- tox
31+
- tox -e codecov

‎appveyor.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
environment:
2+
VENV: "%APPVEYOR_BUILD_FOLDER%\\venv"
3+
4+
matrix:
5+
- TOXENV: dist
6+
- TOXENV: py27
7+
- TOXENV: pypy
8+
- TOXENV: py34
9+
- TOXENV: py35
10+
- TOXENV: py36
11+
- TOXENV: py37
12+
- TOXENV: pypy3
13+
14+
matrix:
15+
allow_failures:
16+
- TOXENV: pypy3 # until we get pypy3 in chocolatey
17+
18+
# https://www.appveyor.com/docs/how-to/rdp-to-build-worker/
19+
init:
20+
- ps: if (Get-ChildItem Env:ENABLE_RDP -ErrorAction SilentlyContinue) {iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))} else {echo RDP not enabled}
21+
- echo "TOXENV- %TOXENV%"
22+
23+
install:
24+
- if "%TOXENV%"=="pypy" choco install python.pypy
25+
- if "%TOXENV%"=="pypy3" choco install python.pypy3
26+
- py -3.7 -m venv "%VENV%"
27+
- "%VENV%\\Scripts\\activate"
28+
- python -c "import sys; print(sys.version)"
29+
- pip install -r requirements.tox.txt
30+
- ps: Update-AppveyorBuild -Version "v$(python get_version.py) b$Env:APPVEYOR_BUILD_NUMBER"
31+
32+
build_script:
33+
- tox
34+
- tox -e codecov
35+
36+
artifacts:
37+
- path: "dist\\*"
38+
39+
# https://www.appveyor.com/docs/how-to/rdp-to-build-worker/
40+
on_finish:
41+
- ps: if (Get-ChildItem Env:ENABLE_RDP -ErrorAction SilentlyContinue) {$blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))} else {echo RDP not enabled}

‎get_version.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import sys
2+
3+
import versioneer
4+
5+
6+
sys.stdout.write(versioneer.get_versions()["version"])

‎requirements.test.py2.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
atomicwrites==1.1.5
2+
attrs==18.1.0
3+
-e .[test]
4+
coverage==4.5.1
5+
funcsigs==1.0.2
6+
future==0.16.0
7+
more-itertools==4.3.0
8+
pathlib2==2.3.2
9+
pluggy==0.7.1
10+
py==1.5.4
11+
pytest==3.7.2
12+
scandir==1.9.0
13+
six==1.11.0
14+
tox==3.2.1
15+
virtualenv==16.0.0

‎requirements.test.py3.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
atomicwrites==1.1.5
2+
attrs==18.1.0
3+
-e .[test]
4+
coverage==4.5.1
5+
future==0.16.0
6+
more-itertools==4.3.0
7+
pluggy==0.7.1
8+
py==1.5.4
9+
pytest==3.7.2
10+
six==1.11.0
11+
tox==3.2.1
12+
virtualenv==16.0.0

‎requirements.tox.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pluggy==0.7.1
2+
py==1.5.4
3+
six==1.11.0
4+
tox==3.2.1
5+
virtualenv==16.0.0

‎setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@
7979
"dbf": [],
8080
"json": [],
8181
"sym": [],
82-
"codec": ["bitstruct"]
82+
"codec": ["bitstruct"],
83+
"test": ["coverage", "pytest", "pytest-cov", "tox"],
8384
},
8485

8586
packages = find_packages("src"),

‎src/canmatrix/tests/__init__.py

Whitespace-only changes.

‎src/canmatrix/tests/test_canmatrix.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import decimal
2+
3+
import canmatrix.canmatrix
4+
5+
6+
def test_signal_defaults_to_decimal():
7+
signal = canmatrix.canmatrix.Signal(
8+
offset=4,
9+
factor=2,
10+
)
11+
12+
assert isinstance(signal.offset, decimal.Decimal)
13+
assert isinstance(signal.factor, decimal.Decimal)

‎test.sh

100644100755
File mode changed.

‎tox.ini

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[tox]
2+
envlist = py{27,34,35,36,37}, pypy{,3}
3+
4+
[testenv]
5+
deps=
6+
py27,pypy: -r {toxinidir}/requirements.test.py2.txt
7+
py3{4,5,6,7},pypy3: -r {toxinidir}/requirements.test.py3.txt
8+
passenv=
9+
TOXENV
10+
CI
11+
TRAVIS
12+
TRAVIS_*
13+
APPVEYOR
14+
APPVEYOR_*
15+
commands=
16+
python -c 'import sys; print(sys.version)'
17+
pytest -s --basetemp={envtmpdir} canmatrix --cov-config={toxinidir}/.coveragerc --cov=canmatrix --pyargs {posargs}
18+
coverage report
19+
20+
[testenv:dist]
21+
envdir={toxworkdir}/{envname}_env
22+
commands=
23+
python -c 'import sys; print(sys.version)'
24+
python setup.py sdist --formats=gztar,zip --dist-dir={toxinidir}/dist
25+
python setup.py bdist_wheel --universal --dist-dir={toxinidir}/dist
26+
27+
[testenv:codecov]
28+
deps=
29+
codecov==2.0.15
30+
commands=
31+
codecov
32+
33+
[testenv:old_tests]
34+
commands=
35+
./test.sh

0 commit comments

Comments
 (0)