Skip to content

Commit e09fc11

Browse files
authored
TST: use nox for testing (#160)
* TST: use nox for testing Separates conda install from pip installs in Travis config. The reason is that nox isn't playing nice with conda. I got a "could not find _remove_dead_weakref" when trying to install pip packages when conda was also present. * TST: add global pyenv so binaries appear with right aliases.
1 parent 1fb6c00 commit e09fc11

10 files changed

+148
-37
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ dist
6868
**/wheelhouse/*
6969
# coverage
7070
.coverage
71+
.nox
7172

7273
# OS generated files #
7374
######################

.travis.yml

+35-33
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,50 @@ sudo: false
33
language: python
44

55
env:
6-
- PYTHON=2.7 PANDAS=0.19.2 COVERAGE='false' LINT='true'
7-
- PYTHON=3.5 PANDAS=0.18.1 COVERAGE='true' LINT='false'
8-
- PYTHON=3.6 PANDAS=0.20.1 COVERAGE='false' LINT='false'
9-
- PYTHON=3.6 PANDAS=MASTER COVERAGE='false' LINT='true'
6+
- PYTHON=2.7 PANDAS=0.19.2 COVERAGE='false' LINT='true' PYENV_VERSION=2.7.14
7+
- PYTHON=3.5 PANDAS=0.18.1 COVERAGE='true' LINT='false' PYENV_VERSION=3.5.4
8+
- PYTHON=3.6 PANDAS=0.20.1 COVERAGE='false' LINT='false' PYENV_VERSION=3.6.1
9+
- PYTHON=3.6 PANDAS=MASTER COVERAGE='false' LINT='true' PYENV_VERSION=3.6.1
1010

1111
before_install:
1212
- echo "before_install"
1313
- source ci/travis_process_gbq_encryption.sh
1414

1515
install:
16-
- wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
17-
- bash miniconda.sh -b -p $HOME/miniconda
18-
- export PATH="$HOME/miniconda/bin:$PATH"
19-
- hash -r
20-
- conda config --set always_yes yes --set changeps1 no
21-
- conda config --add channels pandas
22-
- conda config --add channels conda-forge
23-
- conda update -q conda
24-
- conda info -a
25-
- conda create -q -n test-environment python=$PYTHON
26-
- source activate test-environment
27-
- if [[ "$PANDAS" == "MASTER" ]]; then
28-
conda install -q numpy pytz python-dateutil;
29-
PRE_WHEELS="https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com";
30-
pip install --pre --upgrade --timeout=60 -f $PRE_WHEELS pandas;
31-
pip install -e 'git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=api_core';
32-
pip install -e 'git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=core';
33-
pip install -e 'git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=bigquery';
16+
# work around https://github.com/travis-ci/travis-ci/issues/8363
17+
# https://github.com/pre-commit/pre-commit/commit/e3ab8902692e896da9ded42bd4d76ea4e1de359d
18+
- pyenv install -s $PYENV_VERSION
19+
- pyenv global system $PYENV_VERSION
20+
- REQ="ci/requirements-${PYTHON}-${PANDAS}" ;
21+
if [ -f "$REQ.pip" ]; then
22+
pip install --upgrade nox-automation ;
3423
else
24+
wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
25+
bash miniconda.sh -b -p $HOME/miniconda ;
26+
export PATH="$HOME/miniconda/bin:$PATH" ;
27+
hash -r ;
28+
conda config --set always_yes yes --set changeps1 no ;
29+
conda config --add channels pandas ;
30+
conda config --add channels conda-forge ;
31+
conda update -q conda ;
32+
conda info -a ;
33+
conda create -q -n test-environment python=$PYTHON ;
34+
source activate test-environment ;
3535
conda install -q pandas=$PANDAS;
36-
fi
37-
- pip install coverage pytest pytest-cov flake8 codecov
38-
- REQ="ci/requirements-${PYTHON}-${PANDAS}"
39-
- if [ -f "$REQ.pip" ]; then
40-
pip install -r "$REQ.pip";
41-
else
36+
pip install coverage pytest pytest-cov flake8 codecov ;
4237
conda install -q --file "$REQ.conda";
38+
conda list ;
39+
python setup.py install ;
4340
fi
44-
- conda list
45-
- python setup.py install
4641

4742
script:
48-
- pytest -v --cov=pandas_gbq --cov-report xml:/tmp/pytest-cov.xml pandas_gbq
49-
- if [[ $COVERAGE == 'true' ]]; then codecov ; fi
50-
- if [[ $LINT == 'true' ]]; then flake8 pandas_gbq -v ; fi
43+
- if [[ $PYTHON == '2.7' ]]; then nox -s test27 ; fi
44+
- if [[ $PYTHON == '3.5' ]]; then nox -s test35 ; fi
45+
- if [[ $PYTHON == '3.6' ]] && [[ "$PANDAS" == "MASTER" ]]; then nox -s test36master ; fi
46+
- REQ="ci/requirements-${PYTHON}-${PANDAS}" ;
47+
if [ -f "$REQ.conda" ]; then
48+
pip install coverage pytest pytest-cov codecov ;
49+
pytest -v --cov=pandas_gbq --cov-report xml:/tmp/pytest-cov.xml pandas_gbq ;
50+
fi
51+
- if [[ $COVERAGE == 'true' ]]; then nox -s cover ; fi
52+
- if [[ $LINT == 'true' ]]; then nox -s lint ; fi

ci/requirements-3.5-0.18.1.pip

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
google-auth==1.4.1
22
google-auth-oauthlib==0.0.1
3-
mock
43
google-cloud-bigquery==0.29.0

ci/requirements-3.6-0.20.1.conda

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
google-auth
22
google-auth-oauthlib
3-
mock
43
google-cloud-bigquery

ci/requirements-3.6-MASTER.pip

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
google-auth
22
google-auth-oauthlib
3-
mock
3+
git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=api_core
4+
git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=core
5+
git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=bigquery

docs/source/changelog.rst

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changelog
22
=========
33

4+
0.5.0 / TBD
5+
-----------
6+
7+
- Tests now use `nox` to run in multiple Python environments. (:issue:`52`)
8+
49
0.4.1 / 2018-04-05
510
------------------
611

docs/source/contributing.rst

+13
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,19 @@ Or with one of the following constructs::
268268

269269
For more, see the `pytest <http://doc.pytest.org/en/latest/>`_ documentation.
270270

271+
Testing on multiple Python versions
272+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
273+
274+
pandas-gbq uses `nox <https://nox.readthedocs.io>`__ to automate testing in
275+
multiple Python environments. First, install nox.
276+
277+
.. code-block:: shell
278+
279+
$ pip install --upgrade nox-automation
280+
281+
To run tests in all versions of Python, run `nox` from the repository's root
282+
directory.
283+
271284
.. _contributing.gbq_integration_tests:
272285

273286
Running Google BigQuery Integration Tests

nox.py

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
"""Nox test automation configuration.
2+
3+
See: https://nox.readthedocs.io/en/latest/
4+
"""
5+
6+
import os.path
7+
8+
import nox
9+
10+
11+
PANDAS_PRE_WHEELS = (
12+
'https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83'
13+
'.ssl.cf2.rackcdn.com')
14+
15+
16+
@nox.session
17+
def default(session):
18+
session.install('mock', 'pytest', 'pytest-cov')
19+
session.install('-e', '.')
20+
session.run(
21+
'pytest',
22+
os.path.join('pandas_gbq', 'tests'),
23+
'--quiet',
24+
'--cov=pandas_gbq',
25+
'--cov-report',
26+
'xml:/tmp/pytest-cov.xml',
27+
*session.posargs
28+
)
29+
30+
31+
@nox.session
32+
def test27(session):
33+
session.interpreter = 'python2.7'
34+
session.install(
35+
'-r', os.path.join('.', 'ci', 'requirements-2.7-0.19.2.pip'))
36+
default(session)
37+
38+
39+
@nox.session
40+
def test35(session):
41+
session.interpreter = 'python3.5'
42+
session.install(
43+
'-r', os.path.join('.', 'ci', 'requirements-3.5-0.18.1.pip'))
44+
default(session)
45+
46+
47+
@nox.session
48+
def test36(session):
49+
session.interpreter = 'python3.6'
50+
session.install(
51+
'-r', os.path.join('.', 'ci', 'requirements-3.6-0.20.1.conda'))
52+
default(session)
53+
54+
55+
@nox.session
56+
def test36master(session):
57+
session.interpreter = 'python3.6'
58+
session.install(
59+
'--pre',
60+
'--upgrade',
61+
'--timeout=60',
62+
'-f', PANDAS_PRE_WHEELS,
63+
'pandas')
64+
session.install(
65+
'-r', os.path.join('.', 'ci', 'requirements-3.6-MASTER.pip'))
66+
default(session)
67+
68+
69+
@nox.session
70+
def lint(session):
71+
session.install('flake8')
72+
session.run('flake8', 'pandas_gbq', '-v')
73+
74+
75+
@nox.session
76+
def cover(session):
77+
session.interpreter = 'python3.5'
78+
79+
session.install('coverage', 'pytest-cov')
80+
session.run('coverage', 'report', '--show-missing', '--fail-under=40')
81+
session.run('coverage', 'erase')

pandas_gbq/tests/test__query.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11

22
import pkg_resources
33

4-
import mock
4+
try:
5+
import mock
6+
except ImportError:
7+
from unittest import mock
58

69

710
@mock.patch('google.cloud.bigquery.QueryJobConfig')

requirements-dev.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
flake8
2+
google-cloud-bigquery
3+
nox-automation
4+
pandas
5+
pytest
6+
setuptools

0 commit comments

Comments
 (0)