Skip to content

TST: use nox for testing #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ dist
**/wheelhouse/*
# coverage
.coverage
.nox

# OS generated files #
######################
Expand Down
68 changes: 35 additions & 33 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,50 @@ sudo: false
language: python

env:
- PYTHON=2.7 PANDAS=0.19.2 COVERAGE='false' LINT='true'
- PYTHON=3.5 PANDAS=0.18.1 COVERAGE='true' LINT='false'
- PYTHON=3.6 PANDAS=0.20.1 COVERAGE='false' LINT='false'
- PYTHON=3.6 PANDAS=MASTER COVERAGE='false' LINT='true'
- PYTHON=2.7 PANDAS=0.19.2 COVERAGE='false' LINT='true' PYENV_VERSION=2.7.14
- PYTHON=3.5 PANDAS=0.18.1 COVERAGE='true' LINT='false' PYENV_VERSION=3.5.4
- PYTHON=3.6 PANDAS=0.20.1 COVERAGE='false' LINT='false' PYENV_VERSION=3.6.1
- PYTHON=3.6 PANDAS=MASTER COVERAGE='false' LINT='true' PYENV_VERSION=3.6.1

before_install:
- echo "before_install"
- source ci/travis_process_gbq_encryption.sh

install:
- wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda config --add channels pandas
- conda config --add channels conda-forge
- conda update -q conda
- conda info -a
- conda create -q -n test-environment python=$PYTHON
- source activate test-environment
- if [[ "$PANDAS" == "MASTER" ]]; then
conda install -q numpy pytz python-dateutil;
PRE_WHEELS="https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com";
pip install --pre --upgrade --timeout=60 -f $PRE_WHEELS pandas;
pip install -e 'git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=api_core';
pip install -e 'git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=core';
pip install -e 'git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=bigquery';
# work around https://github.com/travis-ci/travis-ci/issues/8363
# https://github.com/pre-commit/pre-commit/commit/e3ab8902692e896da9ded42bd4d76ea4e1de359d
- pyenv install -s $PYENV_VERSION
- pyenv global system $PYENV_VERSION
- REQ="ci/requirements-${PYTHON}-${PANDAS}" ;
if [ -f "$REQ.pip" ]; then
pip install --upgrade nox-automation ;
else
wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
bash miniconda.sh -b -p $HOME/miniconda ;
export PATH="$HOME/miniconda/bin:$PATH" ;
hash -r ;
conda config --set always_yes yes --set changeps1 no ;
conda config --add channels pandas ;
conda config --add channels conda-forge ;
conda update -q conda ;
conda info -a ;
conda create -q -n test-environment python=$PYTHON ;
source activate test-environment ;
conda install -q pandas=$PANDAS;
fi
- pip install coverage pytest pytest-cov flake8 codecov
- REQ="ci/requirements-${PYTHON}-${PANDAS}"
- if [ -f "$REQ.pip" ]; then
pip install -r "$REQ.pip";
else
pip install coverage pytest pytest-cov flake8 codecov ;
conda install -q --file "$REQ.conda";
conda list ;
python setup.py install ;
fi
- conda list
- python setup.py install

script:
- pytest -v --cov=pandas_gbq --cov-report xml:/tmp/pytest-cov.xml pandas_gbq
- if [[ $COVERAGE == 'true' ]]; then codecov ; fi
- if [[ $LINT == 'true' ]]; then flake8 pandas_gbq -v ; fi
- if [[ $PYTHON == '2.7' ]]; then nox -s test27 ; fi
- if [[ $PYTHON == '3.5' ]]; then nox -s test35 ; fi
- if [[ $PYTHON == '3.6' ]] && [[ "$PANDAS" == "MASTER" ]]; then nox -s test36master ; fi
- REQ="ci/requirements-${PYTHON}-${PANDAS}" ;
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
- if [[ $COVERAGE == 'true' ]]; then nox -s cover ; fi
- if [[ $LINT == 'true' ]]; then nox -s lint ; fi
1 change: 0 additions & 1 deletion ci/requirements-3.5-0.18.1.pip
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
google-auth==1.4.1
google-auth-oauthlib==0.0.1
mock
google-cloud-bigquery==0.29.0
1 change: 0 additions & 1 deletion ci/requirements-3.6-0.20.1.conda
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
google-auth
google-auth-oauthlib
mock
google-cloud-bigquery
4 changes: 3 additions & 1 deletion ci/requirements-3.6-MASTER.pip
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
google-auth
google-auth-oauthlib
mock
git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=api_core
git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=core
git+https://github.com/GoogleCloudPlatform/google-cloud-python.git#egg=version_subpkg&subdirectory=bigquery
5 changes: 5 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

0.5.0 / TBD
-----------

- Tests now use `nox` to run in multiple Python environments. (:issue:`52`)

0.4.1 / 2018-04-05
------------------

Expand Down
13 changes: 13 additions & 0 deletions docs/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,19 @@ Or with one of the following constructs::

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

Testing on multiple Python versions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

pandas-gbq uses `nox <https://nox.readthedocs.io>`__ to automate testing in
multiple Python environments. First, install nox.

.. code-block:: shell

$ pip install --upgrade nox-automation

To run tests in all versions of Python, run `nox` from the repository's root
directory.

.. _contributing.gbq_integration_tests:

Running Google BigQuery Integration Tests
Expand Down
81 changes: 81 additions & 0 deletions nox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
"""Nox test automation configuration.

See: https://nox.readthedocs.io/en/latest/
"""

import os.path

import nox


PANDAS_PRE_WHEELS = (
'https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83'
'.ssl.cf2.rackcdn.com')


@nox.session
def default(session):
session.install('mock', 'pytest', 'pytest-cov')
session.install('-e', '.')
session.run(
'pytest',
os.path.join('pandas_gbq', 'tests'),
'--quiet',
'--cov=pandas_gbq',
'--cov-report',
'xml:/tmp/pytest-cov.xml',
*session.posargs
)


@nox.session
def test27(session):
session.interpreter = 'python2.7'
session.install(
'-r', os.path.join('.', 'ci', 'requirements-2.7-0.19.2.pip'))
default(session)


@nox.session
def test35(session):
session.interpreter = 'python3.5'
session.install(
'-r', os.path.join('.', 'ci', 'requirements-3.5-0.18.1.pip'))
default(session)


@nox.session
def test36(session):
session.interpreter = 'python3.6'
session.install(
'-r', os.path.join('.', 'ci', 'requirements-3.6-0.20.1.conda'))
default(session)


@nox.session
def test36master(session):
session.interpreter = 'python3.6'
session.install(
'--pre',
'--upgrade',
'--timeout=60',
'-f', PANDAS_PRE_WHEELS,
'pandas')
session.install(
'-r', os.path.join('.', 'ci', 'requirements-3.6-MASTER.pip'))
default(session)


@nox.session
def lint(session):
session.install('flake8')
session.run('flake8', 'pandas_gbq', '-v')


@nox.session
def cover(session):
session.interpreter = 'python3.5'

session.install('coverage', 'pytest-cov')
session.run('coverage', 'report', '--show-missing', '--fail-under=40')
session.run('coverage', 'erase')
5 changes: 4 additions & 1 deletion pandas_gbq/tests/test__query.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@

import pkg_resources

import mock
try:
import mock
except ImportError:
from unittest import mock


@mock.patch('google.cloud.bigquery.QueryJobConfig')
Expand Down
6 changes: 6 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
flake8
google-cloud-bigquery
nox-automation
pandas
pytest
setuptools