Skip to content

Commit 42f2180

Browse files
committed
TST: use nox for testing
1 parent 1fb6c00 commit 42f2180

File tree

10 files changed

+114
-13
lines changed

10 files changed

+114
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,10 @@ install:
2626
- source activate test-environment
2727
- if [[ "$PANDAS" == "MASTER" ]]; then
2828
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';
3429
else
3530
conda install -q pandas=$PANDAS;
3631
fi
37-
- pip install coverage pytest pytest-cov flake8 codecov
32+
- pip install nox-automation
3833
- REQ="ci/requirements-${PYTHON}-${PANDAS}"
3934
- if [ -f "$REQ.pip" ]; then
4035
pip install -r "$REQ.pip";
@@ -45,6 +40,9 @@ install:
4540
- 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+
- if [ -f "$REQ.conda" ]; then pip install coverage pytest pytest-cov codecov ; pytest -v --cov=pandas_gbq --cov-report xml:/tmp/pytest-cov.xml pandas_gbq ; fi
47+
- if [[ $COVERAGE == 'true' ]]; then nox -s coverage ; fi
48+
- if [[ $LINT == 'true' ]]; then nox -s lint ; fi

ci/requirements-3.5-0.18.1.pip

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 13 additions & 0 deletions
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

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

pandas_gbq/tests/test__query.py

Lines changed: 4 additions & 1 deletion
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

Lines changed: 6 additions & 0 deletions
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)