Skip to content

Commit edb0487

Browse files
committed
Try tox.
1 parent ab67020 commit edb0487

File tree

5 files changed

+105
-109
lines changed

5 files changed

+105
-109
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88

99
*.coverage
1010

11+
*.tox
12+
1113
build
1214

1315
dist
1416

1517
debug_script.py
1618

17-
test_output.txt
19+
test_output.txt

circle.yml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,47 @@ machine:
22

33
environment:
44

5-
PLOTLY_PACKAGE_ROOT: /home/ubuntu/${CIRCLE_PROJECT_REPONAME}
65
PLOTLY_CONFIG_DIR: ${HOME}/.plotly
7-
PLOTLY_PYTHON_VERSIONS: 2.7.8 3.3.3 3.4.1
8-
PLOTLY_CORE_REQUIREMENTS_FILE: ${PLOTLY_PACKAGE_ROOT}/requirements.txt
9-
PLOTLY_OPTIONAL_REQUIREMENTS_FILE: ${PLOTLY_PACKAGE_ROOT}/optional-requirements.txt
6+
TOX_TESTENV_PASSENV: PLOTLY_TOX_*
7+
PLOTLY_TOX_PYTHON_27: /home/ubuntu/.pyenv/versions/2.7.10/bin/python2.7
8+
PLOTLY_TOX_PYTHON_34: /home/ubuntu/.pyenv/versions/3.4.3/bin/python3.4
9+
PLOTLY_TOX_PYTHON_35: /home/ubuntu/.pyenv/versions/3.5.0/bin/python3.5
1010

1111
dependencies:
1212

1313
override:
1414

15-
# run all the pre-written installers (this will take a *while*)
16-
- bash circle/setup.sh
17-
18-
# install testing tools for circle's version of things
19-
- pip install nose coverage
15+
# install everything tox knows about and the plotly package.
16+
- pip install tox
17+
- tox --notest
2018
- pip install -I .
2119

2220
# we need to cd out of the project root to ensure the install worked
2321
- cd ~ && python -c "import plotly"
2422

2523
cache_directories:
2624

27-
- "~/.pyenv/versions" # attempt to just cache installed pyenv things
25+
# cache everything that tox installs for us.
26+
- .tox
2827

2928
test:
3029

3130
override:
3231

33-
# run test suite in all our python versions
34-
- bash circle/test.sh
32+
# test in 2.7 with coverage.
33+
- tox -e py27-core,py27-optional -- --with-coverage --cover-package=plotly
34+
- mkdir "${CIRCLE_ARTIFACTS}/2.7" || true
35+
- coverage html --omit="*/tests*" -d "${CIRCLE_ARTIFACTS}/2.7" --title=2.7
36+
37+
# test everything else. see "envlist" matrix in tox.ini for more info.
38+
- tox -e py34-core,py34-optional,py35-core,py35-optional
39+
40+
# import it once normally (ensures .plotly exists)
41+
- python -c "import plotly"
3542

3643
# test that it imports when you don't have write permissions
3744
- sudo chmod -R 444 ${PLOTLY_CONFIG_DIR} && python -c "import plotly"
3845

3946
# test that giving back write permissions works again
4047
# this also has to pass the test suite that follows
4148
- sudo chmod -R 777 ${PLOTLY_CONFIG_DIR} && python -c "import plotly"
42-
43-
# test core things in the general 2.7 version that circle has
44-
- nosetests -x plotly/tests/test_core --with-coverage --cover-package=plotly
45-
- mkdir "${CIRCLE_ARTIFACTS}/2.7" || true
46-
- coverage html -d "${CIRCLE_ARTIFACTS}/2.7" --title=2.7

circle/setup.sh

Lines changed: 0 additions & 44 deletions
This file was deleted.

circle/test.sh

Lines changed: 0 additions & 47 deletions
This file was deleted.

tox.ini

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
; Tox is a testing tool that manages virtualenvs for testing multiple Python
2+
; environments in a consistent/controlled way.
3+
4+
; SETTING ENVIRONMENT VARIABLES AND TOX TESTING VARIABLES
5+
;
6+
; You can limit tox testing to certain environments via the `-e` (envlist)
7+
; command line option:
8+
; tox -e py27-core,py34-core
9+
; OR, you can just set the `TOXENV` environment variable, which is handy:
10+
; TOXENV=py27-core,py34-core
11+
;
12+
; Integrating with the virtualenvs in Circle CI is a bit of a pain. For
13+
; whatever reason the "executable" `python35` (at the time of writing) cannot
14+
; be activated directly. Instead the circle.yml file specifies the actual
15+
; binary directly. Because of this, you too have to set the following env
16+
; variables:
17+
; PLOTLY_TOX_PYTHON_27=python2.7
18+
; PLOTLY_TOX_PYTHON_34=python3.4
19+
; ...
20+
; These will be specific to your machine and may not look like the ones above.
21+
; If you're not testing with all the python versions (see TOXENV above),
22+
; there's no need to install and map other versions.
23+
24+
; PASSING ADDITONAL ARGUMENTS TO TEST COMMANDS
25+
; The {posargs} is tox-specific and passes in any command line args after `--`.
26+
; For example, given the testing command in *this* file:
27+
; nosetests {posargs} -x plotly/tests/test_core
28+
;
29+
; The following command:
30+
; tox -- -a '!slow'
31+
;
32+
; Tells tox to call:
33+
; nosetests -a '!slow' -x plotly/tests/test_core
34+
;
35+
; Which is a nice way to skip slow tests for faster testing cycles.
36+
37+
[tox]
38+
; The py{A,B,C}-{X,Y} generates a matrix of envs:
39+
; pyA-X,pyA-Y,pyB-X,pyB-Y,pyC-X,pyC-Y
40+
envlist = py{27,34,35}-{core,optional}
41+
42+
; Note that envs can be targeted by deps using the <target>: dep syntax.
43+
; Only one dep is allowed per line as of the time of writing. The <target>
44+
; can be a `-` (hyphen) concatenated string of the environments to target
45+
; with the given dep.
46+
47+
; These commands are general and will be run for *all* environments.
48+
[testenv]
49+
deps=
50+
mock==2.0.0
51+
nose==1.3.7
52+
requests==2.12.4
53+
six==1.10.0
54+
pytz==2016.10
55+
optional: numpy==1.11.3
56+
optional: ipython[all]==5.1.0
57+
optional: pandas==0.19.2
58+
optional: scipy==0.18.1
59+
commands=
60+
; Sanity check that we're testing what we *think* we're testing.
61+
python --version
62+
; core: nosetests {posargs} -x plotly/tests/test_core
63+
; optional: nosetests {posargs} -x -a '!matplotlib' plotly/tests
64+
65+
; CORE ENVIRONMENTS
66+
[testenv:py27-core]
67+
basepython={env:PLOTLY_TOX_PYTHON_27:}
68+
69+
[testenv:py34-core]
70+
basepython={env:PLOTLY_TOX_PYTHON_34:}
71+
72+
[testenv:py35-core]
73+
basepython={env:PLOTLY_TOX_PYTHON_35:}
74+
75+
; OPTIONAL ENVIRONMENTS
76+
[testenv:py27-optional]
77+
basepython={env:PLOTLY_TOX_PYTHON_27:}
78+
79+
[testenv:py34-optional]
80+
basepython={env:PLOTLY_TOX_PYTHON_34:}
81+
82+
[testenv:py35-optional]
83+
basepython={env:PLOTLY_TOX_PYTHON_35:}

0 commit comments

Comments
 (0)